Writing Tests for Custom Templates in Google Tag Manager

Google Tag Manager introduced the capability to add tests to your Custom Templates. Tests, in this context, refer specifically to unit tests that you write in order to make sure your template code works in a predictable way. Unit tests are also used to drive development, ensuring that you have added contingencies for all the different scenarios that the template, when coupled with user input, might introduce. In this guide, I’ll introduce how the Tests feature works. Read More…

Community Template Gallery for Google Tag Manager - Introduction and Tips for Use

Since the introduction of custom templates in May 2019, the community (myself included) has been anxiously waiting for some official solution for curating and distributing templates created by the community. Now, finally, we have it. It’s called the Community Template Gallery! Read Google’s announcement in this blog post. I’m not going to go over the basics in this article, since Google’s own documentation stands fine on its own feet. Read More…

User Distributor Custom Tag Template for Google Tag Manager

I’ve enjoyed working with custom templates for Google Tag Manager. A lot. So much so that whenever the need to add some custom code to a container emerges, my first thought is how to turn that into a custom template. Google has been forthcoming in introducing new APIs steadily, and I think the variety of things you can do with template is improving with every new API release. In this article, I’ll show you how to use a simple tag template for distributing your users to groups, based on a random split. Read More…

#GTMTips: Introducing the GTM Templates Library

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. Read More…

How to Build a Google Tag Manager Monitor

Google Tag Manager is strictly a tag delivery system, and it’s very careful not to collect any analytics data on its own. This is most likely a deliberate choice, because if GTM was to start collecting data, it would introduce additional barriers to adoption. Nevertheless, being a tool that consolidates the design, development, deployment, and testing of all the marketing and analytics pixels, code snippets, and utilities running on a website or a mobile app, lacking the necessary features for auditing and monitoring has always seemed like an oversight. Read More…

Enhanced Ecommerce Object Builder Template for Google Tag Manager

One of the cool things about Enhanced Ecommerce deployments in Google Tag Manager is that you can use a Custom JavaScript variable to generate the necessary data. There are many reasons to do so, with the biggest one being the flexibility it offers for manipulating the dataLayer object in case quick changes are required on the site, and it would take too long to wait for a new release of the site JavaScript. Read More…

#GTMTips: Create Facebook Pixel Custom Tag Template

After the recent release of Custom Templates for Google Tag Manager, my mind has been occupied by very little else. However, I have a nagging feeling that due to how involved the feature set is, there’s still a lot of demystifying that needs to take place before templates are fully embraced by the GTM user base. In this article, I want to show you a concrete example of template creation. It’s going to be much more ambitious than the simple walkthrough I explored in the main guide. Read More…

Custom Templates Guide for Google Tag Manager

Last updated 12 August 2020: Added details about server-side tagging. As I have finally managed to pick up my jaw from the floor, it’s now time to tell you what’s got me so excited. Google Tag Manager recently released a new feature called Custom Templates. Actually, it’s not fair to call it a feature. It’s a full-blown paradigm shift in how we use Google Tag Manager. It’s a suite of features designed to help brands, companies, and users create and share their own custom JavaScript and HTML setups with ease, while taking care that the code is optimized for delivery in the web browser. Read More…