简体   繁体   中英

How to track clicks on an element that isn't a link nor a button using Google Tag Manager?

I need to track clicks on an element that is neither a link nor a button, using Google Tag Manager. I've been able to track links and buttons without any problem, but I can't seem to track these elements.

In the image below I have a ul that contains several li . I want to track cliks on the li elements. Each li has class="producto-destacado" This is the code:

<ul class="react-multi-carousel-track">
    <li class="producto-destacado">Content</li>
    <li class="producto-destacado">Content</li>
    <li class="producto-destacado">Content</li>
    <li class="producto-destacado">Content</li>
</ul>

(You can view the actual site here )

在此处输入图像描述

The way I'm tagging now is by creating a trigger of type "All elements > some clicks" and then "Click element > matches CSS selector >.producto-destacado

I've also tried with "All elements > some clicks" and then "Click ID > Equals >.producto-destacado" and not results either.

在此处输入图像描述

*I've also tried the solution posted here , didn't work.

You shouldn't need the . in front of producto-destacado

Try:

Click Classes equals producto-destacado

在此处输入图像描述

The only solution I found was to wrap my <li> tags in <a> tags. That worked for me. Hope this will help someone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM