Persist Google Tag Manager's DataLayer Across Pages

UPDATE 4 June 2020: Instead of copying the Custom HTML code from the article, please load it from the GitHub Gist instead. Four years ago, I wrote an article on how to persist GTM’s dataLayer from page to page. Unfortunately, the solution was a bit clumsy, requiring you to give specific commands for the interactions, which made it really unwieldy in the long run. Google Tag Manager still doesn’t offer us a native way to persist the dataLayer array or its internal data model from one page to the other, so I thought it was about time I revisit this idea. Read More…

#GTMTips: Search DataLayer for a Key-Value Pair

One of the difficulties of working with Google Tag Manager and the dataLayer structure is that GTM doesn’t preserve history of the items collected into its data model. Or, at least, it doesn’t preserve it in a manner that would let us access it. This is typically a very niche problem, but it does surface every now and then. For example, say you wanted to query whether an event with some specific value has already been pushed into dataLayer. Read More…

#GTMTips: The Errors Tab in Preview Mode

While using the Google Tag Manager user interface around Halloween 2018, you might have noticed a new tab in Google Tag Manager’s Preview mode. The tab is named Errors and shows you the number of exceptions thrown by GTM’s tag templates on the page. In this short #GTMTips post, I’ll quickly walk you through what the tab shows. Tip 90: The Errors Tab In Preview Mode The tab’s name is an apt description of what the tab shows. Read More…

Fire GTM Tag Upon Scroll Depth and Time Spent

Over 5 years ago, I wrote an article titled Track Adjusted Bounce Rate In Universal Analytics. It basically explored a number of different methods to tweak the Bounce Rate metric so that it becomes more meaningful in your Google Analytics reports. Now, writing that article wasn’t necessarily my proudest moment. It’s not because the solution was poor, but rather because I was suggesting it makes sense to tweak a metric. The concept of “adjusted Bounce Rate” sounds like the analyst is fixing a metric to be more beneficial to their cause, rather than fixing the business problem that caused the metric to be poor in the first place. Read More…

#GTMTips: Prevent Clicks and Form Submits From Redirecting

Google Tag Manager offers us some nice built-in triggers so that we can automatically listen for specific user interactions on the website, reacting to them however we wish, though typically it would be to fire a tag. The tricky thing especially with the click triggers and form submission tracking is that the page has a nasty habit of redirecting you to the link or form target page before letting you see the respective data in Google Tag Manager’s excellent preview mode. Read More…

Workspace Mode in GTM Tools

It’s time for a big feature update to my GTM Tools, a free tool for managing your Google Tag Manager containers, tags, triggers, variables, and now: workspaces. In this article, I’ll quickly go over the main features of Workspace mode. Be sure to check out the updated Release Notes & User Guide. Introduction First of all, you can access Workspace mode through the container selection screen, or via the container page: Read More…

Enhanced Ecommerce Guide for Google Tag Manager

Enhanced Ecommerce is certainly one of the finest reporting user interface features that Google Analytics has to offer. Enhanced Ecommerce, as the name implies, is a set of dimensions, metrics, and reports, which combine to provide you with a fairly complete view into how users are interacting with your products in your webstore. The main downside of Enhanced Ecommerce is, as with all good things, that it’s complicated to implement. Read More…

#GTMTips: Format Value Option in Google Tag Manager Variables

A very recent addition to Google Tag Manager is the Format Value option in all of GTM’s variables. With Format Value, you can modify the output of the variable with a number of pre-defined transformations. This is extremely handy, because you no longer need to create Custom JavaScript variables whose sole purpose of existence it to change the output of other variables to lowercase, or to change undefined values to fallback strings (e. Read More…

Tracking Cross-Domain Iframes - Upgraded Solution

**Last updated 18 September 2020: Due to how most browsers now have third-party cookie protections in place, this solution will be very ineffective going forwards. You should instead take a look at a cookieless solution. Some years ago, I wrote a post on how to track cross-domain iframes when using Google Tag Manager and Google Analytics. That solution relied on hitCallback to decorate the iframe, and now that I look back on it, it has its shortcomings. Read More…

Create and Update Google Analytics Session Timeout Cookie

In Google Analytics, the concept of a session is the key aggregation unit of all the data you work with. It’s so central to all the key metrics you use (Conversion Rate, Bounce Rate, Session Duration, Landing Page), and yet there’s an underlying complexity that I’m pretty certain is unrecognized by many of GA’s users. And yet, since this idea of a session is so focal to GA (to the point of being overbearing), it’s annoying that the browser isn’t privy to any of the sessionization parameters that Google Analytics applies to the hits sent from the browser to its servers. Read More…