#GTMTips: Auto Link Domains With Regex

Update 5 March 2019 due to GTM not supporting negative lookbehinds any more. Google Tag Manager makes it fairly easy to do cross-domain tracking. Basically, you list the hostnames you want to automatically decorate with linker parameters in the Auto-Link Domains field of your Page View tag, and that takes care of decorating the URLs with the necessary parameter. It’s dead easy, even if there are a bunch of traps you need to watch out for (see my post on troubleshooting cross-domain tracking issues). Read More…

#GTMTips: Add a Load Listener to Script Elements

One of the challenges in working with Google Tag Manager (or any JavaScript-based platform for that matter) is what to do with race conditions. A race condition emerges when you have two resources competing for execution in the browser, and there is a degree of unpredictability to which “wins” the race. A prime example is working with jQuery. It’s one of the most popular JavaScript libraries out there, and websites utilize it for a multitude of things, many useful for Google Tag Manager, too. Read More…

#GTMTips: Respect Opt-Out From Advertising and Analytics

With GDPR looming around the corner, it’s time to explore the options you have at your disposal for respecting the new, stricter regulations for tracking users and for collecting data about their visits to your website. UPDATE 20 June 2018: Google has released the allowAdFeatures field which renders the solution below redundant (at least for the displayFeaturesTask part of it). Please refer to this article for more details on how to conditionally block the advertising hit to DoubleClick. Read More…

#GTMTips: Remove PII From Google Analytics Hits

Sending personally identifiable information (PII) to Google Analytics is one of the things you should really avoid doing. For one, it’s against the terms of service of the platform, but also you will most likely be in violation of national, federal, or EU legislation drafted to protect the privacy of individuals online. In this #GTMTips post, I’ll show you a way to make sure that any tags you configure this solution with will not contain strings that might be construed as PII. Read More…

#GTMTips: Pagination and Quick Search

If you open the Google Tag Manager user interface and browser your tags, triggers, and variables, you might notice that the UI now has two new features: Pagination, where only 50 results are shown per page A quick search / filter bar at the top of each list, which lets you narrow the list down to results that match your query Pagination might be a nuisance in large containers, but it was implemented to improve performance. Read More…

#GTMTips: Track Selection in Drop-Down List

Tracking what a user selects in a drop-down (or select) list/menu can be very useful. This is particularly the case when the selection immediately does something, such as initiate a download or navigate the user to another page. But even if there is no immediate action, it’s still interesting to know what selections users might be doing, if only to uncover yet another piece of the engagement puzzle. Here’s the Google Tag Manager way to do it! Read More…

#GTMTips: Create String From Multiple Object Properties

Facebook’s pixel has an attribute named content_ids (required for Dynamic Ads), which requires an Array of content IDs as its value. It’s very possible you’re running this pixel on a site which already has Enhanced Ecommerce for Universal Analytics implemented, and now you want to use the same Enhanced Ecommerce data that your developers have already made available in this Facebook pixel. Or perhaps you want to concatenate a list of strings, such as article tags (['culture', 'politics']), and send it as a comma-separated string to Google Analytics ('culture,politics'). Read More…

#GTMTips: Send Google Analytics Tag to Multiple Properties

Here we are again, revisiting an old theme. When using Google Tag Manager, we often want to send the contents of the same tag to multiple Universal Analytics properties. With on-page GA, this used to be quite simple, as all you had to do was create a new tracker and then just remember to run the ga('trackerName.send'...) commands to all the trackers (or you could use my duplicator plugin). With GTM, your options are more limited, since Google Tag Manager abstracts the tracker object, giving you far fewer tools to work with. Read More…

#GTMTips: Use CustomTask to Access Tracker Values in Google Tag Manager

One of the things I’ve recommended from the get-go is to always send the Client ID to Google Analytics with your users’ hits. This is very useful for adding a level of granularity to your tracking. At first, I recommended using an Event tag to do this. Then I modified my approach a little so that you could send it with your initial Page View (thus not inflating your hit counts). Read More…

#GTMTips: Enable and Fire Triggers in Google Tag Manager

This is, by no means, a novel topic in this blog. I’ve covered Google Tag Manager’s event tracking and triggers numerous times before (see below). Auto-Event Tracking In GTM 2.0 #GTMtips: Track Outbound Links In GTM V2 #GTMtips: Fix Problems With GTM Listeners Trigger Guide For Google Tag Manager However, based on the number of queries we still see in the Google Tag Manager Product Forums about event tracking, I believe one particular aspect of GTM’s triggers invites revisiting. Read More…