Google Tag Manager Tutorial for Beginners


#1 What is Google Tag Manager? #10 Introduction to GTM Triggers
#2 What is a tag? #11 Firing triggers
#3 Key Benefits of using Google Tag Manager #12 Blocking triggers
#4 Google Tag Manager Container Tag #13 Introduction to GTM Variables
#5 Anatomy of Google Tag Manager Tool #14 Built-in Variables in Google Tag Manager
#6 Google Tag Manager Account Structure #15 Data Layers in Google Tag Manager
#7 Naming Conventions for GTM accounts and containers #16 Setting up Universal Analytics via GTM
#8 Installing Google Tag Manager on a website #17 Migrating all hardcoded tags to Google Tag Manager
#9 Introduction to GTM Tag Templates  #18 Frequently asked questions about Google Tag Manager

What is Google Tag Manager?

Google Tag Manager (also known as GTM) is a free tag management solution provided by Google.

Through this ‘online tool’, you can deploy and manage various marketing and analytics tags on a website or mobile app.

Introduction to Tags

A tag is a bunch of JavaScript code which is used to collect measurement and marketing data from your website/mobile app and then send that data to 3rd party services. 

Get the E-book (72 Pages)

Get the E-Book (62 Pages)


The third party service could be: Google Analytics, Google Adwords, Twitter, Facebook, Comscore etc.

Following is an example of Google Analytics Tag (also known as Google Analytics Tracking code):


Following is an example of Google Adwords Conversion Tracking Tag (also known as Google Adwords Conversion Tracking code):


Following is an example of Facebook Tag (also known as Facebook Pixel Code):

Other examples of tags are:

So you see, that tag is just a snippet of code.

You can add this snippet of code (or tag) directly to your website, by copying-pasting it, in your website template files (like header.php) or you can add the tag indirectly on your website, via Google Tag Manager (GTM).

Advantage of adding the tags via Google Tag Manager

What is the advantage of adding the tags to your website via GTM, when you can simply, directly place them on the website?

The advantage is, when you use GTM to add tags on a website, you get more control over:

  1. When the tag should fire.
  2. When the tag should not fire.
  3. Where the tag should fire.
  4. Where the tag should not fire and
  5. What the tag should do, when it get fired (executed)

In addition to this, via GTM, you can very easily: add, remove, enable or disable any tag on your website.

You can very easily change the functionality of almost any tag.

If you are not using Google Tag Manager, then you need to, manually add or remove the tags from one or many website template files, and you won’t be able to enable or disable these tags.

To disable a tag, you have to remove it from the template files.

To enable the tag, you have to add the tag back in your template files.

This is a lot of work (code changes) esp. if your website is big and use several tags.

Similarly, if you want to change the functionality of a tag, you have to first manually find the template file(s) where the tag is installed and then edit the tag code.

If you are using same tag in several different template files, you may miss to update the tag in some of the template files which can result in data discrepancies.

So when you do not use Google Tag Manager to deploy and manage tags, then your web developer/ IT has to work extra hard to maintain various tags on your website.

This increases your website maintenance cost.

So by not using Google Tag Manager, you end up spending more time and money on tag deployment and management. 

That is why you should use Google Tag Manager.

And above all, GTM is free to useThere is no monthly or yearly fees.

So there is really, no excuse, for not using GTM.

Now watch this short video to improve your understanding of GTM tags and other key concepts:


Key Benefits of using Google Tag Manager

Following are the key benefits of using Google Tag Manager:

#1 GTM removes the need for editing the website code over and over again just for adding, removing or editing tags.

Instead, one code is placed on every page on the website, which is the GTM container code.

This container code literally acts as a container, as it can store and deploy several marketing and analytics tags.

Through GTM user interface, you can: add, edit, enable, disable or remove any tag, with just few button clicks.

No need to hard code the website over and over again just for deploying and maintaining various tags.

#2 Through GTM you can test and deploy tags very fast without hard coding the tags each and every time on your website.

If you want to adapt rapidly and cost efficiently in response to changes in marketing conditions, search engine and social media landscape and competitive landscape then you need to move fast.

You can’t afford to spend weeks or even months, just to add bunch of tags on your website, because your IT team is too busy updating the product catalogues.

A common problem for most online businesses owners/marketers is, over dependence on web developers for any task related to website code which makes them very slow, when it comes to adopting anything agile or lean (agile analytics, agile marketing, lean startup etc). 

With GTM installed on the website, tags can be: added, edited, tested or removed in a matter of minutes.

That means you can move quickly.

For example, if you want to add survey on your website, say for just one day, just add and publish the survey tag to the website via GTM.

Once the day is over, disable the tag. That’s it. 

No heavy coding,  no booking the time with IT, no direct changes to the website code.

#3 GTM makes advanced tracking possible

The biggest advantage of using GTM is that, it makes advanced analytics tracking possible for your website.

GTM provides many in-built tags and variables through which you can implement advanced tracking in short amount of time.

The same task may take several days or weeks without GTM.

For example, say you want to track clicks on all external links on your website, so that you can determine how much traffic the website is sending out to other websites (advertisers, affiliates etc).

If you are using Google Tag manager, you can complete this task in a matter of minutes.

Without using GTM, you will have to add, event tracking code, to each and every external link, which is very time consuming and prone to errors.

Similarly, if you are using Google Tag manager, you can track clicks on ‘submit’ buttons embedded on pages across your website in a matter of minutes.

Without using GTM, you will have to manually add, event tracking code, to each and every submit button on the website, which is very time consuming and prone to errors.

#4 GTM makes tag management very efficient 

When you use GTM, you can add, edit, enable, disable and remove all website tags from one central location.

This ability of the GTM, makes tag management extremely efficient esp. when you have got dozens of marketing and analytics tags on your website.

#5 By using GTM, you can improve website speed 

When you deploy tags via GTM, they are deployed asynchronously, meaning a slow loading tag won’t block other tags from being fired (executed).

Anatomy of Google Tag Manager Tool

If you treat Google Tag Manager tool as a car, then its engine is the container tag and its skin (look and feel) and controls are the user interface.

The container tag provides all the functionality needed for GTM tool, to run and deploy tags on your website.

The user interface makes it easy for you, as an end user, to control the container tag.

Just like, when you drive a car, the car steering, makes it easy for you to control the car engine, make it, turn the car left or right.

When coders refer to GTM, they usually refer to the container tag.

When non-coders refer to GTM,  they usually refer to the user interface.

Thus depending upon the context, GTM can either mean the ‘container tag’ or the ‘user interface’.

Google Tag Manager Container Tag

Google Tag Manager container tag is a two part tag.

What that means, it is made up of two parts.

The following first part of the GTM container tag is placed in the head section (<head>…..</head>) of all of the web pages on your website:

The second part of the GTM container tag is placed immediately after the opening <body> tag of all of the web pages on your website:

If you already have a GTM account then you can see the GTM container code by following the steps below:

Step-1: Login to your GTM account:

Step-2: Click on the ‘Admin’ tab.

Step-3: Click on the ‘Install Google Tag Manager’ link:

You will now see your GTM container tag code:

The GTM Container ID

The part of the GTM containter tag code which reads ‘GTM-TXAAA’, it is called the container ID.

This ID is used to uniquely identify each GTM container tag.

The other part of the code which reads ‘gtm.js‘ is the JavaScript library used by the container tag

Once the container tag code is added to your website, the Google Tag Manager is considered to be installed on your website.

Whenever we refer to GTM in the context of coding, like if someone says “GTM pulls the data from data layer”, we are actually referring to the container tag. 

In short, Google Tag Manager is a container tag.

Setting up Google Tag Manager account

In order to create a GTM account and carry out the tag deployment, read this article: Google Tag Manager Implementation & deployment Guide

Introduction to GTM Tag Templates

A tag template makes it easy to deploy a tag (esp. third party non-google tags) on your website. 

GTM provides dozens of tag templates.

To see the list of all available tag templates, click on the ‘Add a new tag’ link  on the container ‘overview’ page:

Now click on ‘Tag Configuration’:

You can now see the list of all available GTM tag templates:

Note: If you want to create and use your own tag, you can do that via ‘Custom HTML Tag‘ or ‘Custom Image Tag’:

Introduction to Triggers

A ‘Trigger’ is a condition which must be met during run time for a tag to fire or not fire.

There are two types of triggers:

  1. Firing Triggers
  2. Blocking Triggers

To learn more about triggers, read this article: Beginners’ guide to Triggers and Variables in Google Tag Manager

Introduction to Variables

A variable is a storage location in the computer memory.

In the context of GTM, variable is a function which is called from within another tag, trigger or variable.

In GTM a variable is denoted by using the following syntax:

{{Variable Name}} 

There are two types of variables in GTM:

  1. Built-in variables
  2. User Defined variables

To learn more about variables, read this article: Beginners’ guide to Triggers and Variables in Google Tag Manager

Introduction to Folders in Google Tag Manager

Through folders you can organize tags, triggers and variables by project name, team name etc.

For example, you can group all of the tags, triggers and variables related to ‘video tracking‘ by creating a folder called ‘video tracking’ and then adding all of the related tags, triggers and variables to it: 

Note: You can rename or delete a folder and/or add/remove items from the folder at any time.

Introduction to Data Layers in Google Tag Manager

In the context of GTM, a data layer is a JavaScript array which is used to collect and store data from a website and then send that data to the GTM container tag.

Google recommends to use data layers, for retrieving run time information.

Your web developer can set up data layer for you.

This data layer contains all the information you want to send to the container tag.

In order to get the most out of GTM, you need to understand and use data layers.

I have explained data layers in great detail, in the article: Google Tag Manager Data Layer explained like never before.


Frequently Asked Questions (FAQ) about Google Tag Manager

Q. Is Google Tag Manager easy to use for a non-coder? 

Yes but only to a very limited extent.

If you want to considerably modify the way, a tag is fired or should behave, or if you want to implement advanced tracking like: scroll trackingecommerce tracking or enhanced ecommerce tracking then you need to have adequate knowledge of: HTML, DOM and JavaScript.

If you can not traverse a DOM, you won’t be able to get the best out of GTM.

Many non-coders start using GTM on Google’s recommendation but then they quickly get lost during the tags’ setup and configuration.

Once they can’t figure out, what is going wrong, they have no choice but to delegate the set up to a third party GTM expert/agency.

Q. Is Google Tag Manager easy to use for a coder?

Yes but only to an extent.

Though coders/developers have adequate knowledge of: HTML, DOM and JavaScript, they are still not familiar with the Google Analytics Developers environment.

This makes it difficult for them to capture GA data with or without GTM.

Q How do I become a GTM expert?

In order to become a GTM expert, you would need to develop very good knowledge of:

  1. HTML, DOM and JavaScript
  2. Google Analytics Developers environment.
  3. DOM Scraping
  4. At least working knowledge of regular expressions
  5. Working knowledge of a server side language (like PHP) is a bonus.

Q Will Google Tag Manager make me independent from the IT/Web developer?

Yes but only to an extent.

Even when you have got adequate knowledge of HTML, DOM and JavaScript, you would still need the help of client’s web developers/IT.

This is because, if you are not familiar with the server side language used by your client and/or the client’s development environment or database, then you will need the help of client’s IT/web developer, to add server side code to your data layers or to query their database for you.

Without adding sever side code to GTM data layers, you can’t implement many of the sophisticated trackings like ‘enhanced ecommerce tracking’ in GA.

The best practice is, to always involve your web developer / IT (now matter how confident you feel about your tags setup) during tag planning and deployment, as they understand their development environment better than you.

Q Can the use of Google Tag Manager create serious tracking/technical issues on my website?


If you are deploying all of the marketing and analytics tags via the container tag and the container breaks during a website/code update, then all of your website tracking, can stop working immediately.

If you deploy a tag which conflicts with the website code, it can very easily break/modify certain website functionality.

Similarly, if you leave the tags deployed by GTM, hard coded on your website or you deploy the same tags through other tag management solutions, then this can inflate your analytics data.

So you need to be very confident, what you are doing with GTM.

In the wrong hands, GTM can be a dangerous tool.

Q Can I use same container tag on multiple websites?


However the best practice is, not to do that, as it can create tracking issues.

Q Can I deploy GTM container tag code through another TMS (Tag Management Solution)?


But it can prevent GTM from working correctly.

The rule of thumb is, not to use multiple TMS.

Q Are there any tags which can’t be deployed via GTM?


GTM can not be used to deploy: synchronous tags, two part tags, tags that are associated with in-page structure or tags which are not compatible with GTM:

  • Synchronous tags – these tags block rendering of other web page elements when they are executed.
  • Tags associated with in-page structure – like social sharing widgets
  • Two parts tags – Tags with part of the snippet in the header and the other part in footer.
  • Tags not compatible with GTM – For example ‘Facebook JavaScript SDK‘ tag can not be deployed via GTM.

Q Do I have to migrate all of my tags to Google Tag Manager?


However Google recommends to migrate all the tags which are supported by GTM.

Q. Does GTM work, even if you migrate only a subset of tags to Google Tag Manager?


Q Does GTM collect any data?


GTM itself does not collect any data.

However the tags it fires, may collect data.

Q What is the difference between Google Tag Manager and Google Analytics?

GTM is a tag management tool which is used to deploy and manage tags.

Whereas Google Analytics (GA) is a website/mobile app tracking tool which is used to collect, process and report on website usage data.

Q Can I use Google Tag Manager even when I don’t use Google Analytics?


GTM is a tag management solution and can be used to deploy non-google tags.

Q How I can deploy non-google tags via GTM?

Through custom HTML tags or 3rd party tag templates.

Q Does GTM work on mobile websites and mobile apps?


Q Will the use of GTM, slow down my website?


Since GTM fire tags asynchronously, it can actually improve the website speed.

However there is one caveat here.

If your container tag is very large (contains lot of tags, triggers and variables) then it can negatively effect the website speed.

So if you are not using a particular tag, trigger or variable and you have no plan to use it in the future then remove it from the container.

Q Can I use Google tag manager in parallel with hard coded tags?


If complete migration of all of your tags in not possible.

However,you need to make sure that you don’t do double tagging i.e. deploy same tag twice, once via GTM and once without GTM.

Q Will GTM work, if I deploy it, on only a part of my website?


But then it will work, only on those web pages which contain the container tag.

Q Which type of tags are most likely to break my website functionality?

Custom HTML tags. Be very careful with them.

Use tag templates wherever possible esp. if you are brand new to GTM.

Q GTM is protocol relative. What does that mean?

It means it will work on both secure (https) and nonsecure (http) pages alike.

Q What is Google Tag Manager V2 (or GTM V2)?

It is the second and better version of Google Tag Manager. To access GTM V2, navigate to:

Q What is a rule in GTM?

GTM trigger was formerly known as rule.

Q What is a macro in GTM?

GTM variable was formerly known as macro.

Q What is the use of GTM API?

Through GTM API you can programmatically manage: accounts, containers, permissions, variables, tags and triggers.


Resources for Getting Started with Google Tag Manager


Read the following articles one by one, in the order in which they are mentioned:

#1 Google Tag Manager Data Layer explained like never before

To get the most out of GTM, you need to know and use data layers.

This article will teach you to create simple and complex data layers within few minutes. Always remember, GTM works best when used with data layers.

#2 Understanding Triggers and Variables in Google Tag Manager

In order to use GTM, you need to get familiar with the usage of triggers and variables.

This article is going to help you with that.

#3 Google Tag Manager Implementation Guide

Go through this article before you migrate all of your hardcoded tags to GTM.

If you don’t then there is a high probability that you may loose considerable amount of tracking data during migration esp. if your website is big and complex.

#4 Beginners guide to JavaScript for Google Analytics

Google Analytics itself is a JavaScript library and there is heavy use of JavaScript in GTM.

So it is important that you understand what JavaScript is and how it can be used to collect data via GTM.

#5 Introduction to Google Analytics JavaScript Library – Analytics.js

Analytics.js is the engine which power Google Analytics.

Whenever we refer to GA in the context of coding, we are actually referring to the analytics.js JavaScript library.

The first step towards understanding the Google Analytics Developers environment, is to understand the analytics.js JavaScript library.

#6 Introduction to Google Analytics Commands

In order to set up / troubleshoot any GA/GTM implementation, whether it is ecommerce tracking, cross domain tracking, event tracking or enhanced ecommerce tracking, you need to understand how the ga() command queue function works.

#7 Page Tracking in Google Analytics

Through page tracking you can measure the number of times a page was shown to your website users in GA.

This can be done by sending a pageview hit, each time a page is shown.

Implementing Page tracking is another step in understanding the Google Analytics Developers environment.

#8 Advanced Google Analytics Tracking – Introduction to DOM

To get the most out of GTM, you need to know what DOM is and how it can be traversed.

Without adequate knowledge of DOM, you would have hard time implementing any tracking via GTM.

#9 Regular Expression Guide for Google Tag Manager

Regular expressions are frequently used in setting up complex goals and filters in GTM.

Without the use of regex, you will have hard time creating useful triggers in GTM.

#10 Understanding Google Analytics Diagnostic messages and notifications

Google Analytics diagnostic is a feature of Google Analytics through which you can identify and understand implementation issues.

When you are setting up GTM, to deploy various tags on your website, this diagnostic feature will help you a lot in debugging set ups (like ecommerce tracking).

#11 Complete Guide to Google Tag Assistant

Google tag assistant is a chrome extension through which you can troubleshoot the installation of various google tags on a web page.

It is a must have tool for GTM debugging.

#12 Guide to Google Tag Assistant Recordings

Google tag assistant recording is one of the most useful feature of Tag Assistant through which you can see the tags and events which were fired during say checkout process.

You can record tags, events and interactions for any set of pages.


Advanced Google Tag Manager Resources


#1 Implementing E-Commerce Tracking via Google Tag Manager

Learn to Implement E-Commerce Tracking through Google Tag Manager via this easy to understand step by step guide.

#2 Google Tag Manager Workspaces

Learn all about Google Tag Manager Workspaces through this easy to understand guide.

#3 Tracking Virtual Pageviews in Google Tag Manager – Complete Guide

Learn to track virtual pageviews in Google Tag Manager, through this easy to understand, step by step guide.

#4 Cross device tracking with User ID in Google Tag Manager

Learn to implement cross device tracking with User ID in Google Tag Manager through this easy step by step guide.

#5 Setting up Dynamic Remarketing via Google Tag Manager

Learn to set up dynamic remarketing in Google Analytics and Google Adwords via Google Tag Manager.

#6 Event Tracking in Google Tag Manager V2 – Complete Guide

Learn to track Form Submissions, Form Fields, clicks on external links, File downloads and clicks on other buttons via Google Tag Manager.

#7 Cross domain tracking in Google Tag Manager

Learn to implement Cross domain tracking in Google Tag Manager between two or more primary domains and its sub domains.

#8 Implementing Scroll Tracking via Google Tag Manager

Learn to Implement Scroll Tracking through Google Tag Manager via easy to understand step by step guide.

#9 Adjusting Bounce Rate via Google Tag Manager

Learn to adjust bounce rate in Google and Universal Analytics via Google Tag Manager

#10 Why you may no longer need Google Tag Manager

Understand the limitations of Google Tag Manager through this article.

#11 How to install and use Google Tag Manager in

Learn to install and use Google Tag Manager in

#12 Google Tag Manager Content Grouping Setup Guide

Through this article you will learn to set up content grouping in Google Analytics via Google Tag Manager.

#13 Google Tag Manager WordPress Installation Guide

Learn to correctly install Google Tag Manager on your WordPress Website through this easy to understand step by step guide.

#14 Google Analytics Settings Variable in Google Tag Manager Explained

Through this article you will learn to create and use the new ‘Google Analytics Settings’ variable in Google Tag Manager.

#15 Learn to install Google Tag Manager on your Shopify Store

Learn to install GTM on your shopify store through this easy to understand step by step guide.

#16 Learn to correctly setup Google Analytics for Shopify Store while using Google Tag Manager


#17 Scroll Tracking via Scroll Depth Trigger in Google Tag Manager

Learn to use the new Scroll depth trigger in Google Tag Manager,……to track,…how far website visitors scroll contents on your website.

#18 Video Tracking via YouTube Video Trigger In Google Tag Manager

Learn to use the new YouTube Video trigger in Google Tag Manager…to track YouTube Videos embedded on a webpage.

Other article you will find useful: Implementing rollup reporting in Google Analytics 

About Web Analytics Training Course

  • Learn and Master Web Analytics, Conversion Optimization & Google Analytics from Industry Expert in 8 weeks.
  • Lifetime access to the course + Lifelong FREE course updates
  • New study material added every few months (lifelong learning)
  • Up to date training material
  • Most exhaustive course on Google Analytics on the internet.
  • Hundreds of Assessments to test your learning
  • Your 24/7, 365 days a year reference source
  • Learn at your own pace and from any place.
  • Risk Free with 30 days 100% Money Back Guarantee.

Announcement about my books

Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.

Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.

Attribution Modelling in Google Analytics and Beyond
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.

Himanshu Sharma

Certified web analyst and founder of

My name is Himanshu Sharma and I help businesses find and fix their Google Analytics and conversion issues. If you have any questions or comments please contact me.

  • Over eleven years' experience in SEO, PPC and web analytics
  • Google Analytics certified
  • Google AdWords certified
  • Nominated for Digital Analytics Association Award for Excellence
  • Bachelors degree in Internet Science
  • Founder of and

I am also the author of three books:

error: Alert: Content is protected !!