We help IT Professionals succeed at work.

Google Tag Manager - Add Trigger Using Div class

3,853 Views
Last Modified: 2017-04-05
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. ).
Comment
Watch Question

Christopher RourkeQA @ ProductPlan
CERTIFIED EXPERT

Commented:
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.

Author

Commented:
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 RourkeQA @ ProductPlan
CERTIFIED EXPERT

Commented:
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.
Christopher RourkeQA @ ProductPlan
CERTIFIED EXPERT

Commented:
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.

Author

Commented:
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>

Author

Commented:
Never mind, I see! Let me try it, thanks!
Christopher RourkeQA @ ProductPlan
CERTIFIED EXPERT

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

Author

Commented:
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 RourkeQA @ ProductPlan
CERTIFIED EXPERT

Commented:
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.

Author

Commented:
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

Author

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

capture2.JPG
Christopher RourkeQA @ ProductPlan
CERTIFIED EXPERT

Commented:
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

Author

Commented:
That's right, it didn't fire. I'll check that, thanks.

Author

Commented:
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.

Author

Commented:
This must be frustrating for you, you could probably have it running in ten seconds if you had access...
Christopher RourkeQA @ ProductPlan
CERTIFIED EXPERT

Commented:
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.
QA @ ProductPlan
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Author

Commented:
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!

Author

Commented:
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!

Author

Commented:
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?

Author

Commented:
Like: <div class="newclass">Trustpilot widget here</div>, then use .newclass in place of  .tp-widget-wrapper?
Christopher RourkeQA @ ProductPlan
CERTIFIED EXPERT

Commented:
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.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions