#GTMTips: Why Does the Google Analytics Tag Show 'Failed'

I’ve covered the more pervasive issue with tags not firing in Google Tag Manager in my article on the “Still Running” status. However, there’s an additional problem you might face with Google Analytics: tags that show status Failed, and which refuse to send any data to Google Analytics.

There are a couple of possible reasons for this, and we’ll explore them in this article.

Note that any tag type in Google Tag Manager can signal Failed. With the advent of Custom Templates, more and more templates are doing it right, meaning they elicit an explicit Failed status when the tag runs into issues. This isn’t the case with many native templates - they just gobble up the errors and refuse to signal that something went wrong.

Read More…

#GTMTips: Keep IOS and Android Firebase Containers in Sync

With iOS and Android containers available for Google Tag Manager, it’s tempting to add GTM as an integration into an existing Firebase setup for your apps. It’s also a fine way to get acquainted with Firebase in the first place, as it has a plethora of features to make application development easier.

Furthermore, with the advent of App + Web, there’s even more incentive to integrate your app with Firebase.

Adding Google Tag Manager is basically one extra dependency, and even if the feature set at the moment isn’t too spectacular, I’d be surprised if things like custom templates wouldn’t make their way to mobile at some point.

Read More…

#GTMTips: Collect ISP as a Custom Dimension in Google Analytics

Update 6 April 2020: I updated the template in the gallery to the latest version of the IP Geolocation API SDK, which no longer requires jQuery. Also, the SDK now handles API request caching to browser storage automatically, so the “Enable Session Storage” option was added to the template.

Google Analytics had been foreshadowing the deprecation of the Network Domain and Service Provider custom dimensions since late 2019. On February 4, the plug was finally pulled, and both these dimensions started flatlining to (not set) in Google Analytics reports. For more information about this, see these articles:

Read More…

#GTMTips: Chrome Samesite Warnings for Google Tag Manager

Update 17 February 2020: Google Tag Manager’s Preview mode cookies have been updated with the necessary flags, so they will not break once SameSite enforcement begins.

If you’ve opened the browser console in Google Chrome (since Chrome 76), you might have seen a bunch of warnings in a yellow background related to something called a SameSite cookie attribute that is either missing or incompletely set for cookies set on external domains. If you use Google Tag Manager, especially in Preview mode, you might have seen a warning about the http(s)://www.googletagmanager.com domain.

Read More…

#GTMTips: Walkthrough of Custom Template Tests

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.

Read More…

#GTMTips: Track Outbound Link Clicks in Google Tag Manager

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!

Read More…

#GTMTips: The Mysterious .Macro() Call in Custom HTML Tags

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. Read on!

Read More…

#GTMTips: When Click Variables Are Undefined

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.g. Click Classes, Click ID) get. Thus, it’s a chick-and-the-egg situation - you can’t create the trigger until you know what to track, and you can’t track until you create the trigger.

Read More…

#GTMTips: Get Latest Exchange Rates for Client-Side Conversions

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. I’ll show you how!

Read More…

#GTMTips: Enable Preview Mode in the Safari Browser

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.

Read More…