Advanced Google Tag Manager

Arsene Zounon
5 min readJun 20, 2021

Helping other with problems so that you can master any topic

Photo by Brett Jordan on Unsplash

This is the only course by Simo Ahava in this Digital Analytics Minidegree. Even if I regularly read its posts, following this course really show me who he is: a real Master

You know the references to these stars in sports, Michael Jordan, Mohamed Ali, Lionel Messi, Cristiano Ronaldo, Michael Fred Phelps… When it comes to GTM and GA, put Simo Ahava in the same category.

Before going through the chapters of this course, I’m going to ask you to go and learn the basics of JavaScript or any other programing language; it’s essential to follow and really understand.

The only criticism I could have made is the length of the videos. There is even one that is an hour long. But as it’s an advanced course I will say that it is up to the learner to organize their learning by breaking it down.

In this course, you will Understand GTM and its data model, learn useful Javascript skills, and automate tasks using the GTM programmatic API.

The course length is 6h 19min

What you’ll learn:

  • Understand GTM and the GTM data model, useful Javascript skills, and how to automate tasks using the GTM programmatic API
  • Customizing GTM event tracking to track interactions on a site
  • Customizing your Google Analytics setup using Tasks API, hitCallback, the Google Analytics Settings variable, and regular expressions
  • Ins and outs of the dataLayer
  • Turning GTM into a true force of power in your data organization

Summary:

Welcome to the Course

Event Tracking Under The Hood

Custom Event Listeners

The Tracker Object

customTask

Enhanced Ecommerce

API Outline And Resources

Build Your Own API Tool

Templates Introduction

Build Your Own Custom Template

This is not the kind of course where you can easily summarize the chapters.

Event Tracking Under The Hood

You must always use “window” prefix when working with the data layer.

Never re-initialize the data layer

The data layer is an array.

If you push to the data layer, you must use the “event” key as it’s the only that can trigger a Tag. If you don’t use this key, you will see “message” on GTM will not know tag was trigger.

Custom Event Listeners

GTM is already full of events and they are really useful. You will need Custom Event Listeners if you need to listen to fancy or non-default ones. To listen to an event, you have two options:

1- Add listener directly to element

2- Add listener highly in the DOM tree, use event delegation.

GTM use the second method

The Tracker Object

the tracker object is the part of the Universal Analytics library designed to kind of abstract the requests that we send to Google Analytics when we want to collect data.

You can send a field such as user ID, client ID, page, location, refer and so on with just a single hit or you can also set measurement protocol parameters as fields.

customTask

customTask is the most useful tool you can use in Google Tag Manager, when you really want to customize your Google Analytics tracking. It gives you an ability to manipulate the hit to Google Analytics (PII filtering, data duplication…) before it leaves the website. customTask is kind of special task because it has no functionality of its own.

tasks, in the order they are executed:

Task Name

Description

customTask

By default this task does nothing. Override it to provide custom behavior.

previewTask

Aborts the request if the page is only being rendered to generate a ‘Top Sites’ thumbnail for Safari.

checkProtocolTask

Aborts the request if the page protocol is not http or https.

validationTask

Aborts the request if required fields are missing or invalid.

checkStorageTask

Aborts the request if the tracker is configured to use cookies but the user’s browser has cookies disabled.

historyImportTask

Imports information from ga.js and urchin.js cookies to preserve visitor history when a site migrates to Universal Analytics.

samplerTask

Samples out visitors based on the sampleRate setting for this tracker.

buildHitTask

Builds a measurement protocol request string and stores it in the hitPayload field.

sendHitTask

Transmits the measurement protocol request stored in the hitPayload field to Google Analytics servers.

timingTask

Automatically generates a site speed timing hit based on the siteSpeedSampleRate setting for this tracker.

displayFeaturesTask

Sends an additional hit if display features is enabled and a previous hit has not been sent within the timeout period set by the advertising features cookie (_gat).

Enhanced Ecommerce

You will learn how you can take that information and manipulate it with custom scripting in GTM itself so that you don’t have to wait for a new release of the site if you want to make changes to your data collection. We’ll also be talking about attribution in Enhanced Ecommerce because that’s one of the more difficult concepts and how to achieve consistency in your data collection from one Enhanced Ecommerce action to the other.

There is an official Enhanced Ecommerce demo website: https://enhancedecommerce.appspot.com

API Outline And Resources

The API doenst fire TAG or do anything directly in GTM. It allow you to manage account / container operations (example: instantly update a tag across 100 containers ). You can replace certain manual work with a kind of automation.

The resources you need and will use are API Overview and API Reference.

Build Your Own API Tool

Google Sheets use a flavor of JavaScript call Apps Script.

The resources you need and will use are API Overview and API Reference.

Templates Introduction

Custom Templates can be used in Tags or Variables. Instead of finding any script on Google, copy and paste as Custom HTML or JavaScript, you can use Custom template that will be show like built-in Tag. They are more secure and reduce risk of breaking your website.

Build Your Own Custom Template

Container > Templates > Create

If you want to take this course, please go and take Beginner GTM and Intermediate GTM course at CXL Institiute, then practice and master what taught by Chris Mercer. You will tank me for this advice.

When you follow Simo Ahava in this course, were it not for the interface and the references to GTM, you get the impression that this is a computer science course.

But you also realize that GTM and GA are not hermetic tools, designed by Google and that you are obliged to use them as they are delivered. Not at all, because the advanced user can customize them to fit the logic of his business, the need to collect specific data.

At the end of this advanced course, you can think that it all end, you are now a Master of Tag manager. But Simo Ahava as a real leader and professional where to find topic that a Advanced GTM user

FreeCodeCamp

Codecademy

Mode.com sql tutorial

Coursera / Google Cloud platform certificate

Chrome DevTools

Thank you CXL Institute for this great course.

--

--