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.
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.
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 tweethowto: Debug and Monitor your Google Tag Manager implementation with @googleanalytics - check it out Click To Tweet