An intro to Google Tag manager and its feature usage

An intro to Google Tag manager and its feature usage

Google Tag Manager is a recent offering by the search giant to complete its set of digital measurement tools and speed up the implementation of the variety of tracking scripts it offers. GTM allows you to add a single code snippet to the website and then manage all your tracking scripts from its web interface. On first look its a dream come true I have personally spent way too much time poking through code coordinating with developers to appreciate its promise. Having taken it live for a couple of clients  as always its not in itself the solution to all of measurement complications. But it does help in certain aspects.

Here is a brief overview of GTM and how its structured I have drawn some parallels with GA which helped me connect the dots quickly.

In google tag manager a user can create accounts much like google analytics and within each account we can create containers, a container is akin to to a web property and has its own container code that needs to be placed on all pages you may want to track. Ideally container should be for one site but as with GA in cases of multiple web sites connected together it may make sense to have one container code for all sites.

Within each container there are three basic building blocks that combine to make tag manager a powerful solution. Tags (you saw that coming), Rules and Macros.

Tag as the name suggests is the place to add a tracking scripts. Tag manager offers a variety of templates for the most common tags Google Analytics, Adwords Conversion, Remarketing, DoubleClick, Image Tag, Custom html tag and few others.

Second we have Rules which determine when a tag should be executed and when it should be blocked. By default you need atleast one rule to run a tag. A blocking rule supersedes an execution rule and helps manage complexity.

Finally Macros are inputs that GTM can receive from the deployed container to dynamically customize rules and tags. There are several different types of macros and this really is the main power of GTM you can use exisiting page content as input (detecting if the title of page is order confirmation to trigger a goal), receive values from javascript variables or best of all use the dataLayer to pass additional data.

dataLayer warrants special mention because it offers an additional line of abstraction allowing us to decouple data from the tags. At its most basic it can be added to specific pages to set a static value ( for example those following the functional approach can use it to define page types) as simple as:

dataLayer = [{ 'pageType': 'decision' }];

but this can also be used to push new data to gtm whenever a useful action is completed on the page. For example track outbound clicks.

var domain =; $('a[href^="http"]:not([href*="'+domain+'"])').each(function(){ $(this).click(function(){ dataLayer.push({'href': this.href}); // send link url to GTM dataLayer.push({'event': 'outbound'}); // tell gtm about action }); });

Hopefully this gives you some ideas about gtm and how you can start using it make your life easier plus earn the love of IT team by not bothering them so much ;).

I will cover a GA deployment using GTM in my next post. Let me know how you've been using it and any feedback you have.

Hussain Mehmood

Hey I am Hussain Principal Analytics Consultant @ MarketLytics focusing on measurement strategy and analytics implementation. I started marketlytics in 2010 to turn my passion for understanding user behaviour into my day job. I use & extend google analytics, tag manager and kissmetrics everyday to deliver performance measurement & data driven insights.