#GTMtips: DataLayer Declaration vs. .Push()

Here’s a tip on how to avoid a horrible, horrible mistake with Google Tag Manager. Tip 7: Always use .push() with dataLayer When you assign a value to a variable using the equals ( = ) sign, you are actually reallocating the variable to a new value, and the garbage collection system of the runtime environment sweeps the previous value to bit heaven. Let’s put it simply: if you redefine dataLayer after the GTM container snippet, you will break GTM’s proprietary functions. Read More…

ECommerce Tips for Google Tag Manager

I’ve noticed that setting up eCommerce in Google Tag Manager (and now the new Enhanced ecommerce) is very difficult for many. I’m sure part of the problem is that eCommerce is for many users the moment that GTM forces you to take steps in to the developer’s domain, since it’s obvious that you’ll need to add some code to the web page. This isn’t a tutorial on how to do eCommerce in Google Tag Manager. Read More…

#GTMtips: HitCallback and EventCallback

This time we’ll take a look at two different, JavaScript-y features of Google Analytics and Google Tag Manager. Callback as a concept should be familiar to anyone who’s ever used a programming language. It’s basically a piece of code that is passed as an argument to some function, so that when this second function has completed, the callback is executed. For web analytics, callbacks are hugely important, since they allow you to impose a firing order for your asynchronous tags. Read More…

#GTMtips: Chain Macros in Lookup Tables

One of the cool things about using a tag management solution is that you can leverage variables like never before. In Google Tag Manager, these variables are referred to as macros, and you can identify a macro with the syntax of {{macro name}}. In this tip I’ll show you how you can actually call macros from other macros, using a Lookup Table as an example. Tip 5: Chain Macros In Lookup Tables (And Other Macros) It’s not just Lookup Tables, either. Read More…

Google Tag Manager's Data Model

It’s time for MeasureCamp again! As before, I want to write an accompanying post for my session, since there’s always so much more to say than the time slot allows for. So, the topic of this article is the data model used by Google Tag Manager to process digital data in your data layer. This post also picks up where I left in my previous foray into the data layer. However, where the first article aimed to be generic (since the data layer should be generic), this post will look at how GTM uses the information in the generic data layer, and how it processes this information to work with the proprietary features of the tool. Read More…

Use Page Visibility API With GTM

The Page Visibility API for web browsers is pretty sweet. It lets you poll, using some new properties of the document object, whether or not the current page is visible to the user. Visibility is hidden if the page is not open in the current browser tab instance, or if the browser window has been minimized. In this post, I’ll give an example of how features of the Page Visibility API could be used with Google Tag Manager. Read More…

#GTMtips: Undefined Dimensions Won't Get Sent

This might not sound like a tip to you. You might think, “Dimensions won’t get sent? Sounds like a bug!”. You’re wrong. This is one of the awesome features of the GA API, and it’s key to making your tag setups leaner when sending data to Google Analytics. Tip 4: Undefined dimensions are left out of GA hits Note that ‘undefined’ here means the special value undefined in JavaScript. Read More…

The Data Layer

Writing this article is dangerous. Data Layer is two marketers short of becoming a buzz word. This occasion will be heralded by articles such as “Data Layer Is Dead”, “This Developer Implemented A Data Layer And You’ll Never Guess What Happened Next”, and other examples of the kind of content generation whose propagation should be prevented by military force. This is not one of those articles, I hope, but rather an honest look at what Data Layer is from a number of perspectives. Read More…

#GTMtips: Rules in a Nutshell

Rules are the cornerstone of Google Tag Manager. As with any critical element in a system, they are easy to get wrong. This tip is just a refresher on how GTM firing and blocking rules work. Tip 3: Google Tag Manager rules in a nutshell So, let’s go through these points one-by-one. Every tag requires a firing rule to work - this is a given. Without a firing rule, your tag will not be written in the document object, and it will never be executed. Read More…

#GTMtips: Check {{Referrer}} for Previous Page URL

Here’s a simple way to check what was the source of the visitor’s arrival to the current page. It’s done by utilizing the {{referrer}} macro, which comes out-of-the-box in any GTM setup. Tip 2: Use {{referrer}} to see where the visitor came from You might want to also explore the Component Types and create new macros for {{referrer path}} and {{referrer host name}} for example: By default, you see, the {{referrer}} macro returns the entire URL of the previous page. Read More…