Link to home
Start Free TrialLog in
Avatar of Melody Scott
Melody ScottFlag for United States of America

asked on

Google Tag Manager - Add Trigger Using Div class

Hi, I thought I was doing this correctly, but I'm seeing no results in Google Analytics.

I have a Trustpilot review widget on my home page. I want to know if people are clicking on it. My understanding is, you create the trigger to fire when someone clicks on the element with class .trust-pilot, then you add an event that contains that trigger.

This is what I created in Google Tag Manager:

User generated image
User generated image
Hopefully that's enough information for someone to advise me. Let me know if you need more. Thanks. (I do have google tag manager set up on the home page, magickitchen dot com. ).
Avatar of Christopher Rourke
Christopher Rourke
Flag of United States of America image

I've checked your site source and the GTM code appears to be implemented correctly.

Looking at your screenshots I can't tell if you have assigned the trigger you've configured to your Google Analytics tag. Beneath the tag configuration settings there should be a section, "Triggering", that allows you to assign the click trigger to the GA tag.

If that is set already let me know and we can dig deeper.
Avatar of Melody Scott

ASKER

Let me try that again... and thanks!

When I open the tag configuration, I see:

User generated image
then when I click on Home Page Trustpilot Clicks, I see:

User generated image
That all looks correct as well. Next lets try to debug the tag:

  • In Google Tag Manager, load the "Workspace" tab for the Container in which you created your tag and trigger.
  • At the top right of the page there should be a red button, "Publish", with a down arrow next to it. Click the down arrow.
  • Click on the "Preview" option to enable the debugger on your site.
  • Load your website in the same browser that is logged into Google Tag Manager, a debug screen should appear at the bottom.
  • Click on the element that has the matching CSS selector you setup in your trigger and confirm/deny the tag firing in the debug window.
Actually, while writing up my last comment I think I may have found your problem. Your trigger is set for matching the CSS selector .trustpilot-widget but looking at your site it appears the selector you want is, .tp-widget-wrapper.
Interesting... where do you find that? The code for the widget is:

<div class="trustpilot-widget" data-locale="en-US" data-template-id="xxxxx" data-businessunit-id="xxxxx" data-style-height="220px" data-style-width="100%" data-theme="light" data-stars="4,5"></div>
</div>
Never mind, I see! Let me try it, thanks!
Using developer tools in the Chrome browser, see attached:
User generated image
Ok, that's in place, now I should be able to see any clicks on that class in Analytics in Behavior>Events, right? How long should I wait after I click the widget a few times for the data to appear? Thanks!
Can take a bit for you to start seeing data in Analytics (hours approximately). I'd recommend now running through the debug steps I outlined in this earlier comment:

https://www.experts-exchange.com/questions/29009818/Google-Tag-Manager-Add-Trigger-Using-Div-class.html?anchorAnswerId=42079131#a42079131

If you see the tag firing as expected, you'd then need to publish your Google Tag Manager changes at which point the data should flow to your analytics account.
Ok, this is what I get - I'm sorry, now I have to go away until tomorrow... I'll try to check again later tonight. I did click on the trustpilot link, and it opened.
User generated image
oh, and when I clicked on that box with the trustpilot click event, I saw this:

User generated image
And after clicking into the Trust-Pilot widget the tag does not fire?

If so then next we need to ensure your Google Tag Manager container has the built in Click variables enabled. They can be found by clicking on the Variables selector in the left hand navigation. Ensure all Click based variables are enabled:

  • Click Element
  • Click Classes
  • Click ID
  • Click Target
  • Click URL
  • Click Text
That's right, it didn't fire. I'll check that, thanks.
Ok, I have enabled these. They weren't enabled before.
      
Click Classes      
Click Element
Click ID
Click Target
Click Text
Click URL

Then I went back to my site, the bottom tag manager bar reopened, and I clicked on the review widget. Same result, didn't fire.
This must be frustrating for you, you could probably have it running in ten seconds if you had access...
Potentially but no need to worry, I enjoy puzzles and challenges so it is unlikely I'll get frustrated :). We're eliminating possible error points so still making progress.

What are you clicking on in the Trust Pilot widget? The left and right arrows or, an individual review? Does the click result in you leaving your site?

Going to take a few moments to compile what you have set for each portion, now that you have the variables enabled we should be able to put all the pieces together.
ASKER CERTIFIED SOLUTION
Avatar of Christopher Rourke
Christopher Rourke
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi- I'm clicking on an individual review, which does take me to another tab and opens the trustpilot review page.

Ok, I see what you mean. Trustpilot takes our snippet of code and adds substance to it from their side. That's why I initially wasn't sure about the class you mentioned. Interesting.

I read the articles, and it does sound like the easiest thing by far would be to have Trustpilot add the GTM to the iframe.

So I'll ask, although having talked to their support before, I hold out little hope.

Thanks!
Hi- it looks like that can't be done(Putting the gms code in the iframe at the trustpilot side). It's not important enough to continue with on my side. Thanks very much, I learned a lot!
One last dumb question- I couldn't wrap my widget code in another div with a class, and use that class for the event tag?
Like: <div class="newclass">Trustpilot widget here</div>, then use .newclass in place of  .tp-widget-wrapper?
A solid idea but, no. The click would still be to their document which is inserted on your page.

Sorry we could not get this to work; on the bright side, you should now be setup to collect clickEvent tracking for any non-iframe elements on your site.