Google Tag Manager Implementation Guide

Last Updated: August 20, 2022

This article is related to installing Google Tag Manager (GTM) and deploying various marketing and analytics tags.

If you are brand new to GTM, then read this article first: Beginner’s guide to Google Tag Manager

Google Tag Manager Account Structure

You need a Google account to create a GTM account.

You can create multiple GTM accounts from a single Google Account. The rule of thumb is to create one GTM account per company/organization.

If you are a business, then most likely, you need only one GTM account. If you are a business conglomerate, you may have several companies or units. In that case, you would need multiple GTM accounts.

Multiple GTM accounts are often used by marketing agencies because they manage the GTM of several different companies.

You can either create a new GTM account from scratch or you can add an existing GTM account. Marketing agencies generally ask their clients to add them, to their existing GTM accounts.

Following is a visual representation of the GTM account structure:

GTM Accout Structure

You can create/add multiple GTM accounts from a single Google account. So you don’t need to create, several Google accounts for managing multiple GTM accounts.

Each GTM account can have one or more container tags.

The rule of thumb is to create one container tag for each website. So if you have got 3 different websites, then you would create 3 different container tags, one for each website. But you would create these 3 container tags from a single GTM account and from a single Google account login.

If you treat your sub-domain as an entirely different website, then you should create a separate container tag for your sub-domain.

Otherwise use the same container tag for both primary domain and sub-domain.

Each container tag has got one or more tags, triggers and variables.

The tags, triggers and variables are collectively called GTM configurations. You can’t share GTM configurations across containers. So unless your sub-domain is completely unrelated from your primary domain, you should not use a different container tag for your sub-domain.

The GTM account structure can now, also be illustrated like the one below:

Google Tag Manager Implementation Guide

Since the majority of businesses out there have got only one company and one website, their GTM account structure will look like the one below:

GTM Accout Structure3

Now watch the following two short videos to improve your understanding of GTM account structure:


Naming Conventions for GTM accounts and containers

The best practice is to name the GTM account after your company name and your container after the domain name.

For example, if your company name is ‘XYZ Ltd’. and your website name ‘’ then you should name your GTM account ‘XYZ Ltd’ and your container ‘’:

gtm account name

Google Tag Manager Setup Process

Google Tag Manager set up includes following thirteen steps:

  1. Determine tracking requirements
  2. Do Tag Audit of your live website
  3. Create functional and technical designs of your tags
  4. Do tag Deployment Planning
  5. Do the Risk Assessment
  6. Create Project Scope document
  7. Get buy-in from IT
  8. Setup Google Tag Manager Account
  9. Install GTM container tag on the staging website
  10. Create, test and publish tags on your staging website
  11. Install GTM container tag on the live website
  12. Create, publish and test tags on the live website
  13. Do tag audit of your live website.

Step #1: Determine your tracking requirements

Think of all of the information you want to collect.

Think of all of the additional tags you may need, to achieve your tracking objectives.

Your tracking requirements will also depend upon your current migration status like:

  1. Migrating from a non-google product like ‘Omniture’ to Universal Analytics (UA).
  2. Migrating from classic Google Analytics to Universal Analytics.
  3. Migrating from hardcoded Google Analytics tags to the tags deployed via GTM.
  4. Fresh installation of Google Analytics and all other tags via GTM.
  5. Migrating hundreds of different configuration settings along with Classic GA to Universal Analytics via GTM.

If you are migrating from non-google platform and/or migrating along with hundred different configuration settings then your migration is going to be difficult and time consuming and you would need to do lot more planning to minimise risk like data loss.

Step #2: Do Tag Audit of your live website

In tag audit we identify all the tags currently being hard-coded on our website.

We also document following information about each deployed tag:

  1. What is the purpose of this tag? What data it is collecting?
  2. Where the tag is sending the data?
  3. Does the tag still serve our purpose or is it obsolete?
  4. How the tag is collecting the data?
  5. When the tag collects the data?
  6. Where (on which page(s)) the tag collects the data.

You need to document all such information about each deployed tag preferably in an excel document.

Marketing and measurements tags are generally deployed in the global header and footer and/or order confirmation page(s) .

So that is the first place to look for the tags. Some tags are deployed in the body section of the HTML document or tied to a HTML element(s) via event handler.

Manually identifying tags can be quite difficult esp. if the website is big.

That is why you should use crawlers like screaming frog SEO spider or the tools which are specially designed for Tag auditing like: Tag Inspector, web analytics solution profiler or Google Tag Assistant. 

Following is the tag audit report from the ‘Tag Inspector’ tool:

how tags are loaded on this site
tag inspector 1

This report provides following information:

  1. List of all the tags found on a website along with the number of pages on which each tag was found as you can see from the screenshot above.
  2. Details of how each tag was loaded. If a tag is loaded from page source or from GTM. For example from => Google Tag Manager (gtm.js) => Google Universal Analytics (analytics.js), we can conclude that Google Analytics is loaded from GTM.
  3. Provides a list of all the web pages containing a particular tag.
  4. Provides a list of all the web pages on which the tag is missing.
  5. Provides a list of all the cookies set by the tag.

Step #3: Create functional and technical designs of your tags

Functional design is what your tags are supposed to do and technical design is how the intended functionality is to be implemented in code and produce results.

For example you may want to create a tag which tracks publication date of each article. So tracking publication dates will be the functional design of your tag.

The code/process/configuration/data layers that you will use to actually implement this functionality will be the technical design of your tag.

The format in which your tag should produce the output is also the technical design of your tag.

Once you have created functional and technical design of your tags, you can then test the tags on your development website and make sure that it works the way it should before you deploy the tag on the client’s staging website.

On a development website you can run wild with your code and ideas without worrying about messing up the staging website.

Sometimes it is not possible to replicate the functionality of a hard coded tag without working on the staging website. In that case you have no choice but to create and debug tags on the staging website.

But you should always aim to do as much legwork as possible in the development environment, so that you can minimise re-work later in the staging environment when not only you but many more people are responsible for tag deployment and testing.

It is always a good practice to plan your data layers in advance i.e. what data layer variables you will use on each page (esp. product pages and order confirmation page) and how they will be set up.

This is because if data layers need to be hard coded on page(s) then IT need to know about that in advance.

Step #4: Do tag deployment planning

This type of planning includes determining the whole sequence in which you will import tags one by one to GTM without breaking the existing tracking or creating technical issues.

You need to decide in advance whether you will go for complete tag deployment or partial tag deployment.

Complete tag deployment means migrating all of your hard coded tags to GTM.

Partial tag deployment means migrating only a subset of hard coded tags to GTM.

But the whole point of using GTM is to remove the need for editing the website code over and over again, just for adding, removing or editing tags. This objective cannot be accomplished, if you keep tags (other than the container tag) hard coded on your website. So in order to get the full benefit of GTM, you should aim to remove all hard coded tags (other than the container tag) from your website and deploy them via the container tag.

Note: Google recommends complete tag deployment.

Sometimes migration of certain tags to GTM is not technically possible as GTM doesn’t support it.

For example GTM doesn’t support ‘two part tags’.

These are the tags which need to be deployed in two different parts of an HTML document, generally one part goes in the header and the second part goes in the footer.

If you have got ‘two part tags’ then you need to identify them and hard code them.

There are certain tags (like Facebook JavaScript SDK) which can not be deployed via GTM. So you may also have to keep such tags, hard coded on your website.

Sometimes complete migration of all of your hard coded tags is not possible because of the website size and complexity of the tracking.

Determine all those tags which are dependent on each other, as the output from one tag may act as an input for other tag. Such tags need to be deployed simultaneously.

For example if you are manipulating the ecommerce data via a GTM tag then you first need ecommerce tracking set up. If you deploy a tag which manipulates the ecommerce data in some way without first deploying the transaction tag, your tracking will break.

You know it by now that GTM works even if you migrate only a subset of tags. But you need to make sure that you don’t do double tagging during tag deployment.

Double tagging occurs when you leave the tags deployed via GTM, hard coded on your website or when you deploy the same tags through other Tag management solutions.

Double tagging is a bad practice because it can inflate your data or make the data collection inconsistent. So you need to make sure that double tagging doesn’t occur during tag deployment.

Remove the hard coded tag as soon you deploy it via GTM.

Step #5: Do the risk assessment

You need to understand that migrating tags to GTM is not as easy as Google claims, in its blog posts, documentations and videos.

I get lot of cases where marketers get lost during tag deployment via GTM.

Vendors sell Tag Management Solutions (TMS) to marketers with the promise that it will give them independence from the IT department and they can easily use TMS to track almost anything without hard coding tags on the website again. But this is simply misleading and not true.

Tag Management Solution like GTM won’t help you much beyond executing some very basic tasks (like installing Google Analytics tracking code, some very basic event tracking etc on your website) if you know little to nothing about DOM and JavaScript.

The real power of GTM lies in the usage of its variables.

Many times predefined variables won’t do the trick and you need to create custom JavaScript variables, custom HTML tags or use DOM element etc.

All of this require a good knowledge of DOM tree and JavaScript code.

  • Can you drill down to a particular DOM element?
  • Do you understand how debug console works?
  • Do you understand what variable is and how functions and data layer work?
  • Can you confidently debug your GTM installation and/or revert back to the previous working version if something goes wrong with the implementation?

You would need to do such type of risk assessment before you decide to migrate tags on your own or outsource tag deployment to a third party.

In addition to technical expertise, you need to consider following factors too before you start the migration process:

  1. Website size and complexity.
  2. Complexity of the tracking.

Step #6: Create a project scope document

A project scope document outlines all of the project deliverables and identify the constraints, assumptions, resources, cost and milestones.

As the name suggest it clearly defines the scope of the project.

Migrating tags to GTM is a project, both for you and for the IT.

You should create a project scope document to get a buy-in from client/boss and esp. from IT department as they often need to know in advance about your requirements before starting the migration process.

This document is basically a corporate way of saying:

“Hey I am working under the assumption that all of my queries will be resolved in a timely manner and that I will get required access, documents, permissions or any support for my work without prolonged delays and if I don’t then there is no guarantee of project timeline or added expenses”

I use this document a lot. It is a great way to manage clients’ expectations and to avoid any confusion, disagreement or conflict.

I have explained in great detail about creating a ‘project scope document’ in this article: Universal Analytics Upgrade Guide. So check it out.

Step #7: Get buy-in from IT

“Hang on a second, isn’t the whole purpose of using GTM is to get independence from IT?”

Actually this is not the real purpose. The main purpose of using GTM is to speed up and streamline the whole tagging process.

There are lot of blogs out there who can tell you how to use GTM to fix a particular tracking issue and in many cases if you follow the instructions, you can fix your issues. But every time you follow someone’s instructions or use someone’s code without a thorough understanding of your development environment, you bring certain amount of risk with your code/actions.

This risks increases exponentially when you work on a big website which has got dozens of different configuration settings and/or which rely on several third party solutions.

Just because your GTM debugger tells you that you can fire a tag, does not automatically mean that your tag will not create any website issues. Always remember that.

When you choose to bypass IT department by deploying code via GTM, you also take the full responsibility for your code and actions. If anything goes wrong with your code, IT can/will put all the blame on you.

A typical commercial website is updated all the time and if you are not involving IT in your code deployment, they can accidentally break/misplace your container tag or break your data layer.

They may change the element ID you are using in one of your tag rules or just remove the whole element.

Your custom HTML tag can easily break your website functionality and the worst part is neither you nor IT would have any clue what went wrong.

Now imagine you are deploying tags on an airline website. One of your custom HTML tag suddenly broke the shopping cart. You have no idea that shopping cart is not working anymore because your GTM debugger didn’t tell you that.

While you are happy that your tag is firing, the airline company lost millions of dollars in sales within few minutes.

Now who will get the blame? You or the IT department.

I don’t need to explain how much devastating a professional negligence claim brought to you by an airline company can be, for your analytics career and your life.

No matter how good you are in coding, no matter how many years of experience you have got in using GTM, there is always a possibility that you could make a mistake, the mistake which might cost you your job or in worst case, send you to prison.

Not involving IT in your Tag deployment is one of the biggest mistake one can make in his/her career esp. when working for enterprise level clients. Is that little bit of independence from IT, really worth chasing? No. Not in real life.

The sensible way of using GTM or any TMS is to involve IT. Let them know what you are doing via GTM. Keep them in loop.

If you are going to deploy a custom HTML tag, then get it tested by your IT first before you deploy it.

Your testing can never be as exhaustive as the one done by an IT professional because they understand their development environment the best.

IT should always be aware of the code being deployed via GTM. This way when they make certain changes on the website, they make sure that it doesn’t break your tracking.

Similarly, when you deploy certain code on the website via GTM, the IT can make sure that it doesn’t alter/break existing website functionality.

You should also consider restricting tag deployment if more than one person use GTM.

You can blacklist certain tags (esp. custom HTML Tags) and variables through gtm.blacklist if you know that they are known to create website issues once deployed.

Use the project scope document to get a buy-in from the IT department. Make sure they allocate sufficient time for tag deployment work.

Step #8: Setup Google Tag Manager Account

Follow the steps below to create Google Tag Manager (GTM) account:

Step-1: Sign in to GTM: using your Google username and password.

Step-2: Click on the ‘create account’ link on the home page. Generally only one GTM account is needed per company:

create account

Note: You can create/add multiple GTM accounts from a single Google account.

Step-3: Name your new GTM account after your company name (in our case ‘ABC Inc’) and then select your country from the drop down list:

add a new account

Step-4: Select the checkbox ‘Share data anonymously with Google and others’ (to enable benchmarking) and then click on the ‘continue’ button.

Step-5: Enter the name of your container after your website name and then select ‘Web’ (provided you want to use the GTM container on a website)

add a new account2

Step-6: click on the ‘Create’ button.

Step-7: Read the Google Tag Manager Terms of Service Agreement and then click on the ‘Yes’ button:

gtm service agreement

Step-8: If you do business in the European Economic Area then you would first need to read and accept the Data Processing Terms as required by GDPR before you can accept the GTM Terms of Service Agreement.

i accept data processing terms

You have now created new GTM account and container.

Step-6: You will now be shown the code for installing Google Tag Manager. Just click on the ‘ok’ button for now. Once you clicked on the ‘ok’ button, you will see the GTM user interface.

Step #9: Install GTM container tag on the staging website

Navigate to the ‘Admin’ section of your GTM account and then click on the ‘Install Google Tag Manager’ link as shown below:

install gtm 5

Copy-paste the GTM code (aka container tag) on every page of your staging website by following the instructions given by GTM:

install gtm 2

Make sure that your container tag is on every web page, does not break the functionality of staging website or create tracking issues on the staging website.

Google recommends creating one container tag for each web property. So if you have got multiple sub-domains or top level domains, you may need to create multiple container tags, one container tag for each web property.

If you have also got a mobile app, then you also need to create a separate mobile app container tag.

Note: Create a test view in a test GA property (if you already don’t have one) to test various GTM tag implementations on the staging website. In this way you avoid corrupting your existing tracking data for the live website.

Step #10: Create, test and publish tags on your staging website

Create and test tags one by one on the staging website according to your tag deployment plan.

It is important that you create and test one tag at a time. This way you are more likely to spot an issue if something goes wrong.

Tags which are dependent on each other should be deployed simultaneously.

Deploy tags in such a order that it does not break the existing tracking or create technical issues/errors on the staging website.

Create and hard code data layers on the staging website, if your tracking set up required it.

Add your data layer just above the container snippet and initialize it for each web page esp. product pages and order confirmation page(s).

You can get more details about creating data layers from this article:  Google Tag Manager Data Layer explained like never before

Test your tag in ‘preview and debug’ mode. Through this mode you can determine which tags are firing and which are not.

You can see how your staging website looks with updated container draft in your browser and determine (to some extent) whether the tag is working or breaking the website functionality.

Test your tags on different web browsers and devices.

Make sure that the tag is firing from the GTM container and not from the source code of a page. Make sure that the tag is not firing twice and is firing on all of the targeted web pages.

Once you have done your testing, send the preview link of your updated container draft to IT for further testing esp. if you are working on a custom HTML tag or custom JavaScript macro.

Remember GTM debugger does not provide full proof testing.

You can’t just blindly rely on this testing tool alone.

Once you have done your testing, publish tags one by one on the staging website and simultaneously remove the corresponding hard coded tag from the website.

If you published all the tags at once and something goes wrong, you will have a hard time diagnosing the issue.

Step #11: Install a new GTM container tag on the live website

Create and install a new GTM container tag on the live website.

Make sure that this container tag does not break the website functionality.

Test your container tag in different web browsers and devices.

It is important that you keep two different version of your container tag.

Use one container tag for the staging website (called it ‘staging container’) and use a different container tag for the live website (called it ‘live container’).

Maintaining two different versions of the container tag can be challenging but this is required to avoid mishaps on the live website esp. if large volume of transactions are being carried out on the live website.

Step #12: Create, publish and test tags on the live website

Never auto import GTM configurations (Tags, Variables, Triggers) from the staging container to the live container. 

This is because over time, you can not be sure that the staging container is the exact copy of the live container and you don’t want to accidentally overwrite the last known good configuration settings of the live container.

Instead of importing the GTM configurations from the staging container, manually create, publish and test each tag one by one on the live website according to your deployment plan.

Test your tags in different devices and browsers.

Step #13: Do a tag audit of your live website

Now is the time to do another tag audit on the live website.

The purpose of this tag audit is to make sure:

  1. No page is missing the container tag.
  2. Marketing and measurement tags are on all targeted pages.
  3. Each tag is firing and is being fired from the container and not from the source code of a page.
  4. No tag is firing twice
  5. Data layers are all intact
  6. Each tag is working the way it should.
  7. No tag is breaking the existing website tracking and/or functionality.

Setting up Google Analytics via Google Tag Manager

The purpose of this exercise is to make you familiar with the GTM interface and help you, in moving around, with ease. You will learn to create a new tag, debug it and then publish it on a website.

Follow the steps below to set up Google Analytics via GTM:

Step-1: Create new Google Analytics Property (if you don’t have one). If you already have GA property then login into GA via your Google login and password.

Step-2: Navigate to the ‘Admin’ section of your ‘All Website Data’ view:


Step-3: Click on ‘Tracking Code’ link (under Property > Tracking Info):

tracking code

Step-4: Make a note of the tracking ID. You would need this ID later, when you set up Google Analytics via GTM:

tracking id

Step-5: Login to your GTM account and then click on the link ‘Add a new tag’:

add a new tag 1

Step-6: Name your tag ‘Google Analytics Tracking – All Pages’:

enter tag name

Step-7: Click on ‘Choose a tag type to begin setup…’ button:

choose a tag type

Step-8: Select ‘Universal Analytics’ from the list of featured tags:

choose tag type 1

Step-9: Enter the tracking ID of your Google Analytics property in the ‘Tracking ID’ text box:

enter tracking id 1

Step-10: Click on ‘Choose a trigger to make this tag fire…’

choose trigger type

Step-11: Click on ‘All Pages’ trigger as we want the Google Analytics tracking to fire on all the web pages of our website:

all pages trigger

Your entire tag configuration will look like the one below:

tag configuration 2

Step-12: Click on the ‘Save’ button to complete the process of creating a new tag. You will now see your new tag listed under the ‘Tags’ section:

new tag listed

Step-13: Click on the ‘preview’ button to test the tag on your website:

preview button

Once you have clicked on the ‘preview’ button, you will see a message box like the one below:

now previewing workspace

Step-14: Now visit your website, scroll down to the bottom of the window and look for a debugging window, like the one below:

google analytics tracking firing

This debugging window is telling you, that if you publish your Google Analytics tag on the live website, it should fire/execute.

Note: Make sure that, not only the tag is firing but it is also not breaking the website design and/or functionality in any way.

Step-15: Once you have tested your new tag, head back to GTM and click on the ‘Leave Preview Mode’ link :

leave preview mode

Step-16: Click on the ‘Submit’ button in the top navigation:

submit button

Step-17: Enter your version name and version description (like the one below) and then click on the ‘Publish’ button:

submit changes

This action will install Google analytics on your website via GTM .

Step-18: Now remove the Google Analytics tracking code from all of the web pages on your website. If the Google analytics tracking code is not hard coded on your website then you can skip this step.

That’s how you create, debug and publish new tags in Google Tag Manager.

Now watch this short video to improve your understanding of creating, debugging and publishing GTM tags:

Since now you know, how to create and publish a tag via GTM, now is the time to migrate all of the tags hardcoded on your website to GTM.

By migrating I mean, deploying the tags via GTM.

Another article you will find useful: Google Tag Manager Training Resources

Register for the FREE TRAINING...

"How to use Digital Analytics to generate floods of new Sales and Customers without spending years figuring everything out on your own."

Here’s what we’re going to cover in this training…

#1 Why digital analytics is the key to online business success.

​#2 The number 1 reason why most marketers are not able to scale their advertising and maximize sales.

#3 Why Google and Facebook ads don’t work for most businesses & how to make them work.

#4 ​Why you won’t get any competitive advantage in the marketplace just by knowing Google Analytics.

#5 The number 1 reason why conversion optimization is not working for your business.

#6 How to advertise on any marketing platform for FREE with an unlimited budget.

​#7 How to learn and master digital analytics and conversion optimization in record time.


My best selling books on Digital Analytics and Conversion Optimization

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 BeyondSECOND EDITION OUT NOW!
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.

Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.

About the Author

Himanshu Sharma

  • Founder,
  • Over 15 years of experience in digital analytics and marketing
  • Author of four best-selling books on digital analytics and conversion optimization
  • Nominated for Digital Analytics Association Awards for Excellence
  • Runs one of the most popular blogs in the world on digital analytics
  • Consultant to countless small and big businesses over the decade

Get My Step-By-Step Blueprint For Finding The Best KPIs (32 pages ebook)

error: Alert: Content is protected !!