In this post, I will show you how to Debug and Monitor your Google Tag Manager implementation. Monitoring data will be stored in a Google Analytics property, using enhanced ecommerce tracking.
This is part of a GTM container that does a lot more things. Github link here: https://github.com/zjuul/ultimate_gtm_debug_setup
- Completely free
- No complicated Google Cloud setup (no code)
- With a familiar and convenient user interface: Google Analytics
The only thing you’ll have to do is deploy one Custom Tag Template, and setup a Google Analytics property with Enhanced Ecommerce enabled for logging your data.
Quickstart
Below are all the details and instructions. If you’re impatient, here’s the quickstart:
- Check the Monitor template and import it as custom Template tag
- Add the tag to your site, and have it fire on All Events
- Configure the tag so it sends to a separate Google Analytics property.
Done. You can watch the data come in after a preview and publish.
A longer step-by-step guide is below. But first some credits:
Background and inspiration
Since the release of the addEventCallBack function in the GTM custom templates API, a lot of great blog posts have been written on how to create a Google Tag Manager Monitor.
Simo Ahava and Mark Edmondson gave us a GTM Template, which I used as a base template. Also check Doug Hall’s improvements: he adds metadata and a mechanism to find unused triggers.
To store the data, you have some flexibiliy. Simo and Mark use a Cloud Function that collects the pixel and stores it into Big Query.
Eivind Savio uses a GCE Load Balancer system to basically do the same: store the monitoring logs in Big Query this way.
Using Big Query to store the monitoring is a good choice: it’s limitless, low cost, and blazingly fast and flexible.
However: it’s not free, you need a Google Cloud project with billing enabled, and some SQL knowledge (which is always good to have BTW).
My Solution: use the measurement protocol
My monitoring solution is free, and requires only knowledge of GTM and.. Google Analytics, since I will use the measurement protocol to send the monitoring hits to a Google Analytics property of your choice.
Where can you find the data in Google Analytics?
To see the events, how often they occur, and how many tags they send, you can use the Event reports in Google Analytics.
To see details about the individual tags sent, use the Ecommerce reports.
Details of the information sent
- Every monitoring hit that is sent, is of type event, with an added ecommerce action of type transaction
- Event Category: gtm_monitor
- Event Action: the GTM event name
- Event Label: configurable (default is a timestamp)
- Event Value: the number of tags sent in this monitoring hit
- Hostname and Page Path are sent
- Every Tag that is fired and monitored is sent as a product
- Product Name: GTM tag name that fires (or the ID, if no name is set)
- Product SKU: GTM tag ID
- Product Category: the GTM event name
- Product Variant: the tag firing status (success or failure)
- Product Brand: the path name
- Product Price: the tag execution time
- Finally, the transaction has the following properties
- Transaction ID: the timestamp
- Store affiliation: the hostname
- Transaction revenue: the number of tags sent in this monitoring hit
As a bonus, the client id that is used, is configurable as well. The default is to use a timestamp (with a random number attached), but if you have a variable configured with the actual client ID in it, you can use this as well.
Note that for every client ID, there is a limit of 500 hits in Google Analytics, so this setup will not work for sites that fire a decent amount of tags (but remember you can always store the client id in the Event Label.
Step by Step Setup Guide
Set up Google Analytics
As a prerequisite, you will need to create / configure a Google Analytics property where you want the data to land in.
Make sure you enable Enhanced Ecommerce reporting.
Set up The Monitoring tag
Download the template tag file from here, and import it, using the import functions in the Templates section of GTM. Click “Templates” then “New” and look in the top-right section of your screen. There, click import and import your downloaded file.
It does not need any additional configuration or editting, so just save and you’re done.
Add the tag to your workspace
Under Tags, click New, and select the Monitoring tag from the list (it’s under Custom Templates). Then configure it.
The only field that is mandatory is the field where you specify the UA ID of your Google Analytics property.
As a trigger, you should have the tag fire on all events. GTM has no such trigger, so you’ll have to create it.
Optional Extra configuration (for readability)
The Tag Manager monitor by default sends the GTM Tag ID to identify tags. This is a number. Not very friendly for humans. In addition, you can add meta information to your tags, like a Tag Name.
This is achieved by adding the name property to all of your tags. Yes: all of them. Quite some work, but worth it.
For every tag, under Additional Tag Metadata check the box, and type name. Just name, literally.
Preview and Publish
When you preview and / or publish your container, the data should start flowing in.
From the browser developer window, you should see the hits leaving your browser. In the Real-Time reports of GA, you should see the events.
After a while, the ecommerce reports should populate, and voila! You’re done. Let me know what you think in the comments, or via a tweet
[bctt tweet=”howto: Debug and Monitor your Google Tag Manager implementation with @googleanalytics – check it out”]
Erik Altink says
Very nice! Going to play with this soon.
davi duran says
Thanks for the template! It is a great job. But when I wan to set up, show me the next error: “The endpoint must be a valid URL”. It is in the input of ID of property Google Analytics, whit name “Analytics Property to send”.
jules says
Thanks for mentioning. The error message had the wrong default.
I have improved the error message and now use the built in GA_TRACKING_ID check.
– please download the latest version again and the error message is correct.
Make sure you input a UA-number (not a GA settings variable) and you should be fine.
David Duran says
¡Thanks for you time! I goin to check and then I comment results.
Martijn van Vreeden says
I’ve implemented this for a client. Very useful!
Few things I struggle with/ updated to the template:
– wanted to debug differences between conversions for different systems. So I added custom dimensions to the template to send transaction ID to monitoring
– some standard templates return “failed” as tag status. These are impossible to debug or understand what caused the failed status: https://measure.slack.com/archives/C2PNCCZ1V/p1574074929381800
Martijn Van Vreeden says
It seems that once there is a tag with the status “still running” is included on the GTM event, the entire step is not sent… Have you noticed this issue as well?
jules says
Thanks for your comments Martijn. I haven’t encountered failed standard tags yet. Is there a way to force this?
I guess the “still running” doesn’t fire the callback trigger for the monitor tag. Which is unfortunate.
Regarding the adding of custom dimensions: good idea. Right now, only the event label tag can be used as a free field. I’ll consider it in my next iteration (or I’ll consider accepting a pull request :-) )
Martijn Van Vreeden says
Add an ad blocker to see a Google Ads tag return failed. Not sure if you can really consider the GTM tag to have failed, but that’s a way to reproduce a “fail”.
Stefan Koning says
Hi Jules,
Very useful solution!
Some remarks/tips:
– It would be good to have the anonymizeIp setting for GA in there by default in the settings variable. Since it satisfies the requirements of the GDPR and is stated in the briefing of the Authoriteit Persoonsgegevens (https://www.autoriteitpersoonsgegevens.nl/sites/default/files/atoms/files/138._handleiding_privacyvriendelijk_instellen_google_analytics_aug_2018.pdf)
– It would also be useful to have the tag status (success/failed) in a custom dimension on hit level by default. Instead of only in the product variant field.
Keep up the good work Jules!
KR,
Stefan
jules says
Anonymize IP is a great idea, we don’t need it at all for debugging purposes.
Tag status failure is Tag specific, so “product”, not hit specific. One hit (in the monitor) can send multiple Tag statuses, so a custom hit-level dimension will count towards all tags in the hit, and will make it confusing.
Stefan Koning says
Hi Jules,
Sure, that makes sense.
KR,
Stefan
mass says
Thanks for the great template.
It would be great if you could also add a GTM container to keep track of the firing of tags on large sites.
Alex says
Awesome post! The free tier of Firebase once I though about it would not cover my use case. When you add up all those events, it really adds up to a lot of insertions. As for pricing on BigQuery and GCP in general it is hard to bring that up with management when you have no idea as well. Glad to see a GA solution!
Implementing now and may make my own tweaks. Especially looking to do the not firing or anomaly detection. Google Data Studio can pull from Google Analytics, so I am planning on making some nice dashboards.
Here is a nice tip for anyone out there. I have 145 tags in my GTM container, so I was not too excited about updating the meta name on all of them. I was able to export our container and do a search and replace to add the meta name attribute to each tag. Saved lots of time! Then imported the JSON as a merge and it worked perfectly! Just be accurate in your search and replacing.
*Search for:*
“`
“monitoringMetadata”: {
“type”: “MAP”
},
“`
*Replace with:
“`
“monitoringMetadata”: {
“type”: “MAP”
},
“monitoringMetadataTagNameKey”: “name”
“`
Patrick Arnold says
Hello ALex, thank you for your tip :)
I am a beginner on google tag manager.
Please which tool you use to edit and modify the json for *search for* and *replace with* ?
bhargav says
How can I track GTM Triggers and Tags results at the GA4. Can you please make a Video on it.
Thanks.
jules says
Unfortunately, there is no way to find the exact GTM trigger that made the tags fire.
Only the GTM event name that triggered it (in my template they get sent to GA in “Event Action” and “Product Category” – see list above).
Pat says
Hi Jules, i am a new user of GA & GTM.
I downloaded your Ultimate GTM debug setup (GTM debug container) and i am a huge fan of your work :)
Please i have a question : the custom dims & metrics i have to create in GA all have the “hit” scope ?
Thank you