Using trigger values in Matomo Analytics event

I’m trying to set up tag manager so that in addition to a tag for Matomo Analytics of pageviews, I can record clicks on arbitrary bits of UI.

So as I understand it, if I want to record events on a modal box’s closing “X” button, I need to:

  1. Create an “All Elements Click” trigger, where “Click Element” “Matches CSS Selector”: “.modal__close”
  2. Create a tag for Matomo Analytics of Events in which I define modal-closing-specific event category/name/value etc.

In step 1 I called my All Elements Click trigger “Modal closed” and I basically want this name to be the “Event name” I use in my tag setup for step 2.

This way I’d only need to set up one Matomo Analytics Event tag, and I could specify multiple triggers - one for each bit of UI I want to track - which each get to trigger it.

I can’t work out how (or if it’s even intended) to use the name of the trigger to populate the event. The option isn’t there to choose from.

Without being able to do this, it looks to me like I’d have to configure a pair (a Trigger and a new Matomo Analytics Events Tag) for every single custom event I want to record. e.g

new Trigger: Modal open
new Tag: Matomo Analytics Events tag - category “Modal” acton: “open”

Trigger: Modal close
Tag: Matomo Analytics Events tag - category “Modal” acton: “close”

Trigger: Menu open
Tag: Matomo Analytics Events tag - category “Menu” acton: “open”

Trigger: Menu close
Tag: Matomo Analytics Events tag - category “Menu” acton: “close”

I’ve got about 30 UI sections I want to track like this and it seems so avoidable repetitive I’m sure I’m doing something wrong?

Any help would be appreciated

I can’t work out how (or if it’s even intended) to use the name of the trigger to populate the event. The option isn’t there to choose from.

that’s indeed not possible yet. Created https://github.com/matomo-org/tag-manager/issues/146 have a look there for more details.

Thanks for creating an issue.

In the meantime, Is my understanding of what I need to do correct? I’m happy to do the grunt work if that’s what’s required, but I’m still not clear if I’m going about things a suboptimal way.

Is there perhaps a more streamlined interface where new triggers and tags can be configure together? They seem really tightly coupled in a custom event scenario like this. It would certainly be a nice interface to have if it doesn’t exist yet.

Slightly related to this post, we have published this new FAQ: How do I trigger a tag when any DOM element which matches a CSS selector is clicked? FAQ - Analytics Platform - Matomo

Another suggestion (also copied-pasted in the github repo),
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…