April 7, 2020
What to do if Event Tracking in Google Tag Manager is not working?
Google Tag Manager empowers you to track various events on a website and then send that data to tools like Google Analytics where you can analyze. In many standard cases, you can track those events without the developer’s input. However, sometimes you might get stuck when your event tracking is just not working.
While trying to help students of my courses and readers, I’ve noticed some problems that are more common than others. Since I am always advocating for helping at scale, writing troubleshooting guides like this one can definitely help with that.
In today’s blog post, we’ll take a look at the most common issues why your event tracking in Google Tag Manager is not working.
By the way, if none of these tips work for you, let me know in the comments. Describe your problem as detailed as possible (with link to screenshots) and I’ll try to help (and also update the blog post accordingly).
Table of Contents
- #1. Broken data layer
- #2. You haven’t created a trigger
- #3. Using the wrong trigger
- #4. Dealing with an iFrame?
- #5. Trying to use the built-in Form Submission trigger?
- #6. dataLayer.push does not include the event key
- #7. Typos (+ case-sensitive)
- #8. Youtube trigger not working?
- #9. The tag is firing but you can’t see the data in GA Realtime reports?
- #10. Don’t forget to publish your container
- Is Event Tracking in Google Tag Manager still not working?
#1. Broken data layer
Event tracking in Google Tag Manager is relying on the Data Layer. However, a careless configuration on your site might break it.
How can you know whether the Data Layer is broken on your site? Enable Preview and Debug mode and then check what events are displayed on the left side of the debug console.
Normally, you ALWAYS must see AT LEAST 3 events in the preview mode:
If, on the other hand, you see just the DOM Ready and Window Loaded, and instead of the Pageview you see a mysterious Message, you have a problem.
If this is exactly what you see, read this guide on how to fix the Data Layer.
#2. You haven’t created a trigger
This applies to the situations where you are trying to use the built-in triggers in GTM, like Just Links, All Element Clicks, or Form Submission (but not limited to).
Some GTM beginners just enable the related variables (e.g. Click ID, Click Text, etc.) and hope that they will start seeing Click events in the Preview and debug console. However, that is not enough.
You also need to have enabled a trigger to start seeing events in the preview mode (this applies to the built-in event tracking functionality of GTM). So, if we are talking about the link click tracking, you need to complete both steps:
- Enable click-related variables
- Have at least on Just Links trigger enabled on a page (any condition will work)
If you are interested in All clicks, then have at least one enabled All Elements Clicks trigger, etc.
Once you have done that, refresh the preview and debug mode and then interact with the element. Now, you should see that event in the preview console.
#3. Using the wrong trigger
Sometimes, you might be using the wrong trigger to track a particular interaction. Here are several examples.
#1. You are trying to track clicks of an element with a Just Links trigger but that element has no link.
You can inspect that element (Right Click on it > Inspect) and check whether that element is surrounded by <a> tags. If not, this element cannot be tracked with a Just Link Clicks trigger.
#2. Trying to use a Youtube Video trigger on a non-youtube video player
As the trigger name implies, it supports only Youtube video players. If you are dealing with the Vimeo, generic HTML5 player, etc., read this guide.
#4. Dealing with an iFrame?
Chances are that you are trying to track interactions of an element that is in the iframe. In a nutshell, iFrames allow embedding HTML documents on a site. That document can contain just a button, a video player, a reservation form, even the entire website).
The contents of the iFrame can belong to your site but also can be hosted on a totally different domain.
Here’s a situation:
- You are working on mywebsite.com
- And there is a page on your site (mywebsite.com/contact) that contains a form (originally hosted on someotherwebsite.com)
- That form is embedded in an iFrame
- Your GTM container snippet is implemented only on the mywebsite.com and the iFrame does NOT offer the opportunity for you to add some custom code inside of it.
If you are dealing with this situation, you are most likely out of luck and will not be able to track events within that iframe (there are some exceptions, though).
If, on the other hand, you (or your developers) can add some custom code inside that iframe, then you should read this guide.
After reading this chapter, your questions might be:
- How do I know if I’m dealing with an iFrame?
- How can I know if I can add my code inside of that iFrame?
Let’s address them both.
#1. How do I know if I’m dealing with an iFrame? Do the right click on the element that you are trying to track and then in the Elements tab, climb up until you find the <iframe>
If you found it, that’s an iframe. If you haven’t, then the reason why event tracking in Google Tag Manager is not working lies somewhere else.
#2. How can I know if I can add my code inside of that iFrame? Several options:
- Talk to your developers and ask if it’s possible
#5. Trying to use the built-in Form Submission trigger?
If you are trying to track a form on your website and you are using the built-in GTM Form Submission trigger, there are many reasons why it does not work. Read this blog post where I explain everything in greater detail (+ offer solutions)
#6. dataLayer.push does not include the event key
If you want to fire a tag on any dataLayer.push, that push must include an ‘event’ key, for example:
window.dataLayer = window.dataLayer || ;
'event' : 'formSubmitted'
Then you could use a Custom Event trigger and activate your tag. If, on the other hand, the dataLayer.push does not include ‘event’, all you will see in the Preview mode is Message.
Even though it added some data to the Data Layer, you cannot use Message push as a trigger condition.
#7. Typos (+ case-sensitive)
A lot of things in Google Tag Manager are case-sensitive. For example, this means that productid ≠ productID. Keep that in mind when you create triggers. For example, you see a custom dataLayer.push where the ‘event’ key is ‘formSubmission’:
window.dataLayer = window.dataLayer || ;
'event' : 'formSubmitted'
If you created a custom event trigger like this:
it would not work (because you need to use uppercase S).
Also, triple check for typos. For example, if you want to access the attribute key in the dataLayer (I just made that example up), then make sure that you don’t skip any letter (and enter something like atribute (with one “t’)).
#8. Youtube trigger not working?
Are you trying to measure the engagement of your embedded Youtube video player but don’t see any video events in the GTM preview mode? You are not alone. In fact, there are many possible reasons why this is not working. I’ve posted another guide dedicated just to that problem.
#9. The tag is firing but you can’t see the data in GA Realtime reports?
This happens also pretty often. Looking at the GTM preview mode, everything seems to be fine, right? The tag is firing exactly when you expect it to happen. However, when you go to GA > Realtime, that event is not visible. Why?
There are many possible reasons (like GA filters, some configuration in GTM, etc.). To help you troubleshoot this, I’ve posted a blog post some time ago.
#10. Don’t forget to publish your container
Once you have checked whether your events are being tracked properly, don’t forget to publish the GTM container. While you’re in the preview mode, you will see your data in GA properly. However, the rest of your website traffic is still not being measured.
That’s because other visitors are not seeing the preview mode. If you want to make your changes public, you need to publish your GTM container.
To do that, click SUBMIT in the top right corner of your GTM interface and follow all the necessary steps. After you do that, you will start seeing events coming in from all the visitors of your website.
Is Event Tracking in Google Tag Manager still not working?
There are many more possible reasons why your event tracking is not working, however, I wanted to point out the most common ones that I face while helping my students.
If none of these tips helped you, let me know in the comments. Maybe I forgot something to mention or maybe you are facing some new edge case that I should definitely include in the list?
Many of these tips are rookie mistakes. If you want to avoid them and get better with Google Tag Manager, consider downloading my free e-book for GTM beginners below.