Click trigger target data attribute

Hi all

Really impressed so far with Matomo and the Tag Manager. I have a question. I want to target the click event on all elements with a certain data attribute (e.g <div data-name="test">). Is it possible to do this?

Thanks

Hi,

Without trying it out: Did you check [data-name="test"] as a CSS selector?

I was actually trying something similar but couldn’t get it to work

Let say I want an event triggered whenever someone kliks on a link and I want want the data-name as an event name instead of the link txt

<a href="#" class="blue" data-name="whatever">link txt</a>

I need to make a variable from which I can read a value which will act as event ‘name’ so but how? Can’t get it to work