Avatar of Melody Scott
Melody Scott
Flag 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:

trigger
tag configuration
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. ).
GoogleInternet MarketingSearch Engine Optimization (SEO)Web DevelopmentJavaScript

Avatar of undefined
Last Comment
Christopher Rourke

8/22/2022 - Mon
Christopher Rourke

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.
Melody Scott

ASKER
Let me try that again... and thanks!

When I open the tag configuration, I see:

tag.JPG
then when I click on Home Page Trustpilot Clicks, I see:

click1.JPG
Christopher Rourke

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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Christopher Rourke

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.
Melody Scott

ASKER
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>
Melody Scott

ASKER
Never mind, I see! Let me try it, thanks!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Christopher Rourke

Using developer tools in the Chrome browser, see attached:
Screen cap
Melody Scott

ASKER
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!
Christopher Rourke

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#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.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Melody Scott

ASKER
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.
Capture.JPG
Melody Scott

ASKER
oh, and when I clicked on that box with the trustpilot click event, I saw this:

capture2.JPG
Christopher Rourke

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
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Melody Scott

ASKER
That's right, it didn't fire. I'll check that, thanks.
Melody Scott

ASKER
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.
Melody Scott

ASKER
This must be frustrating for you, you could probably have it running in ten seconds if you had access...
Your help has saved me hundreds of hours of internet surfing.
fblack61
Christopher Rourke

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
Christopher Rourke

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Melody Scott

ASKER
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!
Melody Scott

ASKER
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!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Melody Scott

ASKER
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?
Melody Scott

ASKER
Like: <div class="newclass">Trustpilot widget here</div>, then use .newclass in place of  .tp-widget-wrapper?
Christopher Rourke

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.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes