#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…

#GTMtips: Save GATC in a Constant String Macro

I wanted to try something new (and, naturally, I’m running out of content ideas), so let me introduce the hashtag #gtmtips. I hope others contribute as well, but I will be adding a new tip as often as possible. I’ve got maybe 20 tips in store right now, and I’m writing new ones all the time. So without further ado, here’s… Tip 1: Save GATC In A Constant String Macro This is an easy one, and everyone should already be doing this in one way or another. Read More…

Persist DataLayer in Google Tag Manager

(Update 19 November 2018: See this article for a more elegant solution.) If you know your JavaScript, you know that all variables, functions, objects, resources, and data in the document get rewritten with every page load. In other words, every single page refresh builds the page from scratch, and the state of the document before the page refresh is left drifting in the ocean of oblivion. Google Tag Manager’s dataLayer is also one such entity. Read More…

Node Relationships and GTM

There’s a much easier, native-to-GTM way to do this now: the Matches CSS Selector. Behind this tragically boring title is a simple solution to many problems with Google Tag Manager’s auto-event tracking. The common denominator to these problems is poor website markup. Selectors are used sparingly, and element hierarchy is messy. This disregard for proper node relationships means you have to resort to Data Layer Variable Macros which look like Read More…

Custom Event Listeners for GTM

(UPDATE 1 Oct 2014 Due to a change in how macros work in Debug Mode, the {{generic event handler}} macro no longer works when testing in Debug Mode. That means that you’ll have to test your custom listener in a live container (I know, ouch!). If you want to test in Debug Mode, you’ll have to skip using the {{generic event handler}} as a macro, and instead copy the inner function into the Custom HTML Tag, give the function a name, and use that as the callback in addEventListener or attachEvent. Read More…

JavaScript 101 for GTM: Part 2

It’s been an awesome summer, with temperatures soaring in the global warming range throughout our northern country. The heat has given me ample reason to not be near a computer, but now it’s time to mine some JavaScript wisdom again. Here’s the second part of my JavaScript for Google Tag Manager series. The first part focused on GTM specific tips and tricks, and I hope that while reading it, you were treated to another grand example of the flexibility of this wonderful tool. Read More…

Fix GA Site Search With Google Tag Manager

Analyzing what people write in your site search field is pretty much one of the smartest things you can do for your website tracking. If certain terms pop up over and over again in internal search reports, it means that your site is not providing the answers people are looking for, meaning you have an excellent opportunity to provide supply for the demand! However, not all site search applications are trackable out-of-the-box. Read More…

JavaScript 101 for GTM: Part 1

Here’s the link to part 2 of this JavaScript guide. The thing about Google Tag Manager, or any JavaScript tag manager for that matter, is that there’s JavaScript involved. In fact, the tool itself is just a JavaScript library with some additional bells and whistles (such as a management UI). This means that to make the best of it, some knowledge of JavaScript is warranted, and that’s the point of this post. Read More…

Fun With Google Tag Manager: Part 2

Apologies for leaving you hanging. It’s now almost three weeks since I published the first part of this post, and I’m sure you’ve been holding your breath ever since. There’s been a lot going on since the last post. First, my favorite sports team in the world, San Antonio Spurs, won their fifth NBA championship from the defending champs, Miami Heat. Next, my wife and I moved to our new house, and we’ve been remodeling ever since. Read More…