V2 Button Classes & IDs in GTM

Has this been solved? Because it sure isn’t working on my end on the latest version of Pro and it is nearly a year and a half after this post was confirmed as an issue…

What am I doing wrong :-o ?

Hey @DoncoMarketing,

Sorry for the confusion. This is not a bug. But, what happens here is GTM captures the element inside the button because maybe you clicked the text exactly.

Try clicking outside the text but still clicking the button and see what GTM captures. It’s just for testing though. I understand that users will click on the text and this is not the main point. The main point is GTM usage. I’ll get into that after explaining the structure.

Please take a look at the HTML structure of a V2 button below:

<a class="e1851-4 x-anchor x-anchor-button test" tabindex="0" href="#">  
    <span class="x-anchor-content">
        <span class="x-anchor-text">
            <span class="x-anchor-text-primary">Learn More</span>
        </span> 
    </span>
</a>

As you can see, the Button has several layers of span tags inside of it. That is why in the other thread, GTM captures the Classic Button easily because the structure is simple. The anchor tag does not have any markup inside of it.

<a class="x-btn test x-btn-global" href="#" data-options="thumbnail: ''" style="outline: none;">Click Me!</a>

The common thing between the V2 and the Classic button though is the class is applied directly to the anchor or <a> tag. That can be tracked provided that you filter links only. That leads me to the tracker which is GTM.

I’m not an expert with GTM usage but you might be using the All Elements trigger instead of just tracking links. Please watch this video:

Hope that helps.

Interesting – though I can clearly see that no IDs are being pulled through via the GTM preview. Additionally, I kind of need the All Elements trigger vs just Link Tracking because, in this case, it is an anchor link button.

Hey @DoncoMarketing,

I understand that you’re having trouble with GTM. However, there is no problem with outputting the ID and Class of the V2 Button. That is the most important thing to remember here. It’s clearly applied to the <a> tag.

It is the GTM usage that is the problem. I’m not sure how you’re setting it up but you really just need to use Just Links if you want to track a specific V2 Button element.

We do not have GTM support but for the sake of proving it, I tested tracking a specific V2 Button and GTM did successfully tracked it. Please see the screenshot below.

I’d recommend that you consult with a GTM setup expert. Otherwise, please use a Classic Button because its setup is simple as explained previously.

Thanks.

UPDATE: I’ve tested further and you can use All Elements trigger but you need to be specifically tracking each of your buttons by filtering them out using Click Text. Please see the screenshots below.

In this latest sample, I both have All Elements and Just Links triggers in the page and the Just Links tag don’t fire. The All Elements takes precedence in this case so you need to be specifically tracking the button’s text.

Just note that I’d still recommend that you consult with a GTM expert because he/she might have a better idea of how to track elements in your site.

Hope that helps.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.