#GTMTips: Multiple GTM Containers on the Page

For some reason, you might run into a situation where you need to add multiple Google Tag Manager containers on the same page. Usually this is because of poor governance or an inflexible organization. My recommendation is to fix things in your projects first, and only resort to multiple containers if you can’t seem to resolve your governance issues using your vocal cords (or your fists). Officially, Google Tag Manager introduced support for adding multiple containers earlier in 2015. Read More…

#GTMTips: GTM Container Snippet in the HEAD

(UPDATE 28 Sep 2016: The official recommendation has finally caught up with the times. Now the correct placement for the JavaScript methods of the container snippet is, indeed, in <head>.) I want to address something I’ve been confused about from the very first day since I started using Google Tag Manager. Why on earth would an asynchronously loading JavaScript library be recommended to place in the beginning of <body>, when the logical place to start loading dependencies is as early as possible in the document load process? Read More…

#GTMTips: Useful GTM for IOS Tips

A while ago I wrote a blog post about how to install Google Tag Manager for iOS using the Swift programming language (you can read the article here). I’ve been doing a lot of work with Swift lately, and I’m more and more convinced that GTM is actually a very powerful utility for running in your iOS app instead of the Google Analytics SDK. Why? Because it abstracts a lot of the nitty-gritty you’d otherwise need to explicitly manage in your GA installation. Read More…

#GTMTips: Referral Exclusion on Receipt Page

You might have noticed that the Referral Exclusion List in Google Analytics is difficult to maintain. You can’t copy a list from one property to another, the list is a wildcard match for domain names (so all subdomains are automatically excluded), and it’s just about the clunkiest user interface we’ve seen since ERP tools from the 1990s. A while ago, I wrote of a solution which lets you manage referral exclusions using Google Tag Manager, and it’s still a neat trick, as it’s way more flexible than said clunky UI. Read More…

#GTMTips: Check for New User

Every now and then we want to create a bridge between the stateful machines we send data to (e.g. Google Analytics), and the stateless environment where we collect the data itself (e.g. Google Tag Manager). This is not easy. There is no synergy between Google Analytics and Google Tag Manager which would let the latter understand anything about things like sessions or landing pages or Bounce Rates. One thing we can reliably measure, however, is whether or not the visitor is a New User in Google Analytics. Read More…

#GTMTips: Prevent Tag From Firing in IFrame

Unfortunately, iFrames still exist. They are used to embed content from one page into another. Frames are horrible, nasty things, very often riddled with cross-domain problems, performance issues, responsive design obstructions and other crap from the nether pits of hell. Regardless, if you’re stuck with an iFrame which also collects data to your Google Analytics property, for example, you probably want to prevent at least the first Page View from firing, since otherwise you’ll be double-counting Page Views: once on the main page and once in the iFrame. Read More…

#GTMTips: Product-Scoped Custom Dimensions and Metrics

With the advent of Enhanced Ecommerce for Universal Analytics, a new scope was introduced for Custom Dimensions and Metrics. Product scope can be used to send information about each product that is sent through Enhanced Ecommerce, but it’s not exactly the most logical or intuitive thing to wrap your head around. In this #GTMTips post, we’ll take a look at how to implement Product-Scoped Custom definitions via Google Tag Manager, and I’ll quickly explain how they work in relation to queries and reports you might want to build on top of them. Read More…

#GTMTips: Block Your Tags With Trigger Exceptions

To prevent a Tag from firing in Google Tag Manager, you can: Delete the Tag Remove all Triggers from the Tag Add an Exception Trigger to the Tag The third option is usually the best if the blocking is just temporary. Exceptions are what used to be called blocking rules in the first version of GTM. To add them is easy enough. In the Fire On step of Tag creation, you can click Create Exceptions, and choose the Trigger that will block this Tag from firing. Read More…

#GTMTips: Access Array Members in the Data Layer

In JavaScript, if you want to access an Array member, you use square bracket notation to retrieve the value stored at a specific index. Indices are numbered in order, with the first index always being at location zero (0). This means that to get the first value stored in Array simo, you’d use something like: var firstValue = simo[0]; In Google Tag Manager, you can push Arrays into the Data Layer. Read More…

#GTMTips: Implement Referral Exclusions via GTM

Maintaining the list of Referral Exclusions in Google Analytics admin is a pain. Especially if you have a webstore, the number of referral sources you need to exclude to avoid sessions being split can grow really fast. Also, it’s not like the list is has the most intuitive UI. Instead of a handy text area where you could just copy-paste stuff, you’re left with a horrible line-by-line list, and there’s no way of copying lists across properties or anything useful like that. Read More…