Læs også

The bottom navigation of the articles in a story.

How to "story"

Google Tag Manager Basics

This will cover the basics of Google Tag Manager, it'll be way easier for you to learn by doing.

2. november 2015

This article is a short introduction to what Google Tag Manager is and what it can do. In terms of specifics for setup etc I strongly suggest just diggin into, have a look at what has already been done and try a few things out for yourself, there's a lot of documentation on setup of specifc scenario's and there's no need for me to repeat what has already been written by several people.

 

Topics covered in this guide

A short introduction

Tags

Triggers

Variables

Version control

Debugging

A short introduction

Google Tag Manager is a code management platform that fires all of your other tags according to triggers you specify in the Google Tag Manager interface. Google Tag Manager can fire both Google and 3rd party tags. Once the container snippet is deployed on your site or mobile app, little to no IT or web developer involvement is necessary to deploy new tags or edit existing tags.

 

Google Tag Manager doesn't reduce the number of tags on your site or app, but it does simplify the task of managing them. For websites, Google Tag Manager executes asynchronously and can be configured to fire tags only when they are needed, helping your pages to load more quickly.

 

Google Tag Manager keeps track of which tags should fire and the triggers that have been set up to cause those tags to fire. Each time Google Tag Manager is engaged, the most up-to-date tag configuration is sent to the visitor with a set of tags and triggers. As the user interacts with your content, triggers are evaluated based on the events you have specified, and tags will fire accordingly.

Tags

What is Google Tag Manager tags? The simple answer is that tags cover everything you want to track, from implementation of a third party tracking script to a specific event on the website. Whenever you want to track something on the website, you’ll need at least one tag and one trigger (more about triggers later). Since we already have a quite broad setup on our websites, the easiest way to learn how it works is by looking at the tags we have already setup on our sites. Mostly we use 3 different kinds of tags Custom HTML, this is used to implement third party scripts, Custom Image, which is used to implement third party tracking pixels and lastly Universal Analytics tag, this is used to track events and all features that is already supported by Google Analytics.

Triggers

Before Google recently launched their redesign of Google Tag Manager, this was called rules. I am not going to spend much time on semantics here, but since Google Tag Manager is used by lots of different people with different backgrounds, I feel rules better descriptor what this is actually about. Here you basically set up the rules for when each tag should be fired, meaning by making a trigger you are defining when the code from the tag should be executed on the website, and sent to Google Analytics. Again in order to learn how it’s working, it’s a lot easier to have a look at the triggers that are already created. It’s pretty simple and most of them follow the same principles.

Variables

As the name suggest, this is variables that can be used directly in your triggers or tags. These are either built from static values, such as our Google Analytics ID, or from javascript variables that are pushed to the data layer. These make our whole setup a lot easier to manage, since they can be reused through the different tags and triggers, and you would only have to update it one place if anything needs to be updated. Basically the same as our variables and helper classes in SASS.

Version control

Another very important feature in Google Tag Manager is the version control. When doing changes to our Tag Manager setup, you can freely change and update the tags, triggers and variables and test everything works (more about testing later). Whenever you change something it won’t go live before you click the publish button, when you do this, you are asked to create a new version of the build, which is done by the click on a button. Once this is done, you can publish your changes, if for some reason your changes didn’t work as expected you always have the choice to roll back to a previous working version, exactly the same as we have that option on github.

Debugging

One of the more powerful features of Google Tag Manager is the ability to debug and test the tags and triggers you have created. Once you feel confident with your changes and additions to the tag manager setup, before publishing your changes, you have the possibility to test that everything works as expected. If you click the small arrow next to the publish button, you’ll get an option called “Preview and debug”, click this. This will start a test session in your browser, by going to the website you have modified you’ll now get a new interface in the bottom of your browser, this contains all the tags you have created and by clicking around on the website you can check if these are fired correctly. Of course you’ll still have to make sure that everything gets recorded properly in your third party tracking interface or in Google Analytics , 98% of the times this shouldn’t be a problem. But if it is, this could indicate that something is wrong with your tag, since this is not forwarding the statistics properly.