'Internal link tracking with 'matches css selector'

I'm want to track in Google Analytics clicks into internal links on my page using events in GTM.

I'm debugging my tag in GTM Debugger and it shows me that, there's a problem with my trigger rule.

The rule is:

Click classes -> Matches CSS selector -> .cb-feature-1 .cb-l .cb-grid-entry

Here's hierarchy: HTML hierarchy As you can see, there are three links inside div with class .cb-feature-1 .cb-l .cb-grid-entry but all of them are the same so I just want to track all of them together.



Solution 1:[1]

Currently your selector looks like this:

.cb-feature-1 .cb-l .cb-grid-entry

which means it is looking for three nested elements:

<div class="cb-feature-1">
  <div class="cb-1">
    <div class="cb-grid-entry>
       ... (rest of code)

However this is not what your markup looks like, you want to target a single element with three classes. For this you have to remove the whitespace between the elements of your selector:

.cb-feature-1.cb-l.cb-grid-entry

This will look for elements that have all three classes at once. Since you want to target links within those elements you need to look for an anchor tag:

.cb-feature-1.cb-l.cb-grid-entry a 

Solution 2:[2]

Choose "Click Element" instead of "Click Classes".

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eike Pierstorff
Solution 2 richardec