Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the name of a trigger to populate an event / use it as variable #146

Open
tsteur opened this issue Jan 4, 2019 · 7 comments
Open

Use the name of a trigger to populate an event / use it as variable #146

tsteur opened this issue Jan 4, 2019 · 7 comments
Labels
Enhancement New feature or request

Comments

@tsteur
Copy link
Member

tsteur commented Jan 4, 2019

See https://forum.matomo.org/t/using-trigger-values-in-matomo-analytics-event/31092

I can see how this can be useful. At the same time not sure if it is possible to implement and how much it makes sense from the bigger picture meaning variables are used in various places not really only related to tags/triggers. We would need to look into it.

@tsteur tsteur added the Enhancement New feature or request label Jan 4, 2019
@tsteur
Copy link
Member Author

tsteur commented Jan 4, 2019

Actually, I haven't tested but I reckon it should be doable by using eg a DataLayer Variable that reads {{ClickClasses}} and then in advanced settings set up a look up table to translate eg a class to a Modal Open etc.

We could possibly also add the name of the trigger to the dataLayer (name of trigger that was last triggered) but I'm actually not sure we expose the actual trigger name... we might be only exposing a hash... not sure

@tsteur
Copy link
Member Author

tsteur commented Jan 4, 2019

I just double checked we only add the actual trigger name to the preview release for debugging purposes but otherwise set the name to the trigger type. It may be possible to add this variable, but need to see if there is any problem with exposing the name of the trigger/tag/... ?

@Clandboy
Copy link

Clandboy commented Feb 3, 2021

Was there any evolution to use the name of the trigger to feed events?

Indeed this would avoid redundancy in the creation of tags, and ensure the wording, in my case, of the visible elements on a page.

@heurteph-ei
Copy link
Contributor

heurteph-ei commented Apr 14, 2021

Another suggestion (also copied-pasted in the forum),
maybe it could be a good idea for a new feature to be able to capture some attribute(s) value(s). This could maybe solve this issue.
eg: <span my-attibute-1="value i want to capture" my-attribute-2="something else">blabla</span>

Then it could be possible to create a trigger on CSS selector [my-attibute-1] ; configure this selector to capture my-attibute-1 and my-attibute-2 into some datalayer variables and finally create a tag fired by this trigger that will use the datalayer variable populated by the capture...

@peterbo
Copy link
Contributor

peterbo commented Oct 13, 2021

+1 for being able to use the trigger name that triggered a certain tag as a variable.

@heurteph-ei - this is another issue. What you're trying to achieve is already possible (however, it is a bit complex):

  • Create a trigger (e.g. Click) with conditions "Element click" - equals CSS selector - (e.g.) span[my-attribute-1]
  • Create a variable that returns TagManager.dataLayer.get('mtm.clickElement').getAttribute('my-attribute-1');

But I agree with the idea of making this more handy - having this in a more automated manner would be great for another feature.

@tsteur tsteur added this to the Priority Backlog milestone Oct 14, 2021
@jonalange
Copy link

This would really be a good feature. This keeps the tags clean without the need of multiple tags basically doing the same thing just with different names.

@MatomoForumNotifications

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/use-trigger-name-as-eventname-in-tag/45743/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants