2

Through Google Tag Manager, I have successfully made a connection to track page views for my company site. I have debugged this in GTM and also see the "real time" results loading in Google Analytics. But I want to take things further than just page views being tracked. I want to track a GTM variable as a GA event.

For the same Google Tag Manager Workspace, I went to the "Variables" page and created a new variable called "Certain HTML Element Class Name". The point of the variable is to collect the class name found on my <html> element. For example, collect cat from:

<html class="cat">
....
</html>

I am successful in seeing this value displayed in GTM's debug window.

But!!! How in the world do I send that variable data to Google Analytics as an event? I want to see from Google Analytics that every time a page is loaded, GA fires my GTM variable as an event.

Is this possible?

Just to show what I have attempted to do - here are my settings in GTM. Am I on the right track??? Am I missing something? Appreciate any feedback!

enter image description here

1

I feel this is closer to the truth in solving my issue.

  • From GTM, I went into my existing workspace and created a second Tag. I called this one IT Apps Certain Event Tracking. For the settings...
    • I assigned the GA Universal Analytics.
    • I then assigned the Track type to Event.
    • I then filled in the Action, label and value fields. For value, I assigned {{Certain HTML Element Class Name}}.
    • For Google Analytic Settings, I assigned my {{Google Analytics Settings}} variable.
    • Finally, I attached my trigger, IT Apps - Certain Page Views.

After publishing these settings in GTM, I was able to go into the GA and see my events firing under the "Real time" section. I feel happy about this and can't wait until I start seeing my results (values) for my events kicking in.

  • 1
    Thanks for sharing! – closetnoc Sep 29 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.