Search code examples
google-tag-manager

Google Tag Manager: trigger click on div ID with other elements inside


I have created a couple of click triggers in Google Tag Manager to track some areas of my site and I was surprised that the figures were so low. I have realised why but couldn't find a way around it.

Code example:

<li id="myUniqueID"><i class="material-icon">mail_outline</i></li>

If I create a click trigger on "myUniqueID", it only captures the clicks in the area outside the space occupied by the icon. If I click right into the icon, the listener is not fired.

Is there a way to capture all clicks based on a unique ID or class that would take clicks of all sub-elements into account.

It's probably something stupid that I have overlooked.

Thanks!


Solution

  • Change your trigger to Click All Elements that Match a CSS Selector.

    As a selector, try using #myUniqueID, #myUniqueID *

    The second selector selects all descendants/children of whoever has the myUniqueID id.