You are here: Tags / gtmtips
Google Tag Manager now lets you add unit tests directly to your custom templates. This is useful, since it allows you to control the code stability of your templates, especially if you’ve decided to share those templates with the public. I recently shared a general guide for how template tests work, but I wanted to expand the topic a little, and share with you two walkthroughs of custom template tests: one for a variable template and one for a tag template.

Continue reading

I’ve written about outbound link click tracking before. It’s a very solid way to track interactions on the site, as clicking a link that leads away from a site is a signal of … well, something. In Google Tag Manager it’s now extremely easy and efficient to track outbound link clicks, thanks to the introduction of a new configuration in the Auto-Event variable. This article will introduce the new method and show you how you can quickly set it up!

Continue reading

When previewing Custom HTML tags in Google Tag Manager you’ve almost certainly run into a situation where the GTM variable shows up as a weird JavaScript method resembling something like this: google_tag_manager["GTM-ABCD123"].macro(15) And this is when you were expecting it to show the actual, resolved value! It doesn’t help that every now and then the preview mode actually shows to correct value in the preview mode. What’s up with that? Well, there’s a fairly logical explanation to this.

Continue reading

A surprisingly common question in forums and communities seems to be why the built-in Click variables show up as undefined in Google Tag Manager’s Preview mode, even if you click around the site. In this article, I’ll walk you through some of the reasons why this might happen. Tip 104: What to do when Click variables are undefined Here’s the situation: you want to create a Click trigger for your tags, but in order to do so, you’d need to see what values the built-in Click variables (e.

Continue reading

It’s been a while since I’ve last written a bona fide Google Tag Manager trick, so here comes. This was inspired by Bart Gibby’s question in Measure Slack. The purpose is to fetch the latest currency exchange rates from the exchangeratesapi.io service, cache them using sessionStorage, and push the results into dataLayer. From dataLayer, they can then be utilized in Custom JavaScript variables and custom variable templates to perform client-side conversions.

Continue reading

With Intelligent Tracking Prevention, the Safari browser is on a crusade against cross-site tracking. One of the most obvious and long-standing ways to battle cross-site tracking has been to block third-party cookies in the web browser, and this is exactly what Safari does by default. However, Google Tag Manager’s Preview mode relies on a third-party cookies, so that it can serve you the draft version of the container while serving the regular, live container to your site visitors.

Continue reading

When Custom Templates were released in Google Tag Manager, many of us active in the GTM communities started doing two things: 1) creating our own custom templates, and 2) waiting patiently for Google to release a “gallery” or “library” for distributing these community contributions. While I have full faith in the latter happening some time in the future, I thought it would be fun to create something similar to a library, and then open-sourcing it for the community to help out with or to download locally for their own purposes.

Continue reading

Author's picture

Simo Ahava

Husband | Father | Analytics developer
simo (at) simoahava.com

Senior Data Advocate at Reaktor

Finland