MeasureSchool logo

The Google Tag Manager Tutorial for Beginners

Last Updated: October 4, 2023

Are you new to Google Tag Manager but want to learn what GTM is all about and how to use it?

Google Tag Manager is a powerful tracking tool that is used by almost all digital marketers. 

In this Google Tag Manager tutorial, we’ll learn what GTM is all about and how to effectively use it for tracking purposes.

GTM For Beginners

Sign up to the FREE GTM for Beginners Course...

An overview of what we’ll cover:

Let’s dive in!

How Google Tag Manager Works

Google Tag Manager is an all-in-one Tag management system that allows us to integrate all our tracking needs into one user-friendly interface without constantly implementing various codes on our system. 

You can install the scripts manually by adding pixel code to the website. These are known as the marketing Tags

Installing the Pixel codes to the website script

You can also access your code editor to customize the script according to your needs. You can also have an overview of all the codes installed on your website from this code. 

Customizing the website script to manually add codes to track pageviews by users

However, Google Tag Manager eliminates this need to implement various codes. You can simply install the central snippet of Google Tag Manager on your page.

Accessing Google Tag Manager snippets to manually install them to the website script

After implementation of the code, all your Tags can be managed through the graphic interface of the Google Tag Manager system. 

Analyzing the graphic user interface of the Google Tag Manager account

You simply need to configure the data that you wish to track and create triggers for each data set. Triggers are the rules that define intervals or times at which your Tags get fired. 

Finally, you can configure the Tag and send it over to the marketing vendors. After successfully deploying the Tag, GTM implements your tracking codes in the background. 

In addition to this, there are several advantages of using Google Tag Manager. 

You have a version control system that allows you to control any published changes on your website, a preview mode to test your Tags before they go live, and a management function that helps to monitor everything. 

Overall, this is a more flexible and granular way to organize your marketing Tags. 

We’ll learn about more of such functionalities as we move forward in this guide. 

GTM Overview

Let’s learn the basic overview of GTM with the help of an example. 

Before we start with the example, let’s understand the prerequisites for setting up GTM Tags. 

As we mentioned earlier, we’ll need to install the GTM code scripts into our account to implement codes on various tools like Google Analytics or Facebook.

So we have the Global Site Tag script from Google Analytics that we can install on our website.

Accessing Global Sit Tag snippets to manually install them to the website script

For demonstration purposes, we have created a demo website that we’ll use to configure our Tags. 

We have already configured Global Site Tag and Facebook Pixel to the website. You can access the configured scripts from the Google Tag Assistant extension of the browser. 

Accessing the configured codes to the website from the Google Tag Assistant legacy extension

Open the source codes of the website by right-clicking on the website tab and navigating to the View page source

Viewing the page source to access the source codes of the website

If your configuration is successful, you’ll be able to see the Facebook Javascript code as well as the Global Site Tag installed on the source code.

Analyzing the code snippets from the page source of the website

Following is another demo website created for the purpose of configuring Tags. Let’s open the source code for that website. 

There aren’t any excess codes added to this website. We can only see one snippet for Google Tag Manager. 

Analyzing the Google Tag Manager snippet from the website source code

This is what Google Tag Manager is really all about. It eliminates the need to configure various tracking codes. 

Henceforth, we can deploy all our various tracking codes and Tags through this all-in-one central management interface called Google Tag Manager. 

Open the Tags section on your Google Tag Manager account. You’ll find all the Tags that you deployed for your website in one single place. 

Accessing various Tags from the Tags section in the Google Tag Manager account

When you open a Tag, you’ll realize that all of the Tags are implemented in the form of templates, not codes. 

You can see the Tags on a visual interface and configure them accordingly. 

For example, we have a Facebook Pixel Tag configured on our website. All we need to do is add a Facebook Pixel ID, and we can implement this Tag. 

Configuring a Tag with Facebook Pixel type configuration

Similar to the Tag interface, Google Tag Manager brings various other functionalities that can ease the process of Tag implementation. 

One such feature is the preview option. 

Preview Mode

When you click on the Preview mode for your website, it will put your browser into a special mode that connects to your website. 

Entering the preview mode of the website to analyze tracking changes to the website

Hence, you can verify the Tags deployed on your website.

For example, the preview mode for our website shows the various Tags we configured to our website under the category called Tags Fired

Verifying the deployed Tags by Google Tag Manager from the Google Tag Assistant tab in the preview mode

Preview mode is especially useful for debugging, tracking or finding errors in our implementation. This is much easier than finding errors in the codes configured in our websites. 

This was just one feature provided by Google Tag Manager. Another such feature is called the trigger.

Triggers

As we mentioned earlier, triggers are the rules that define intervals or times at which your Tags get fired. 

For example, the triggers for the Tags on our website are on All Pages. This means the Tags we configured will deploy on all the pages of our website. 

Analyzing the trigger configuration of the fired Tags from the Google Tag Manager account

However, we can also add exceptions to the triggers that will allow our Tags to deploy only on specific pages or interactions.

Let’s understand this with the help of an example.

Suppose we want to track when someone clicks on the Add to cart option on our website. 

Selecting the add to cart option on the website to generate data for tracking

Open your Google Tag Manager account, and navigate to Triggers → New

Creating a new trigger from the triggers section of the Google Tag Manager account

Give an appropriate name to the trigger, and click on the Trigger Configuration to add a trigger type. 

Configuring an add to cart trigger from the Google Tag Manager account

This will give you all the different templates to create a new trigger. In our case, we’ll choose the All Elements type trigger. 

Selecting an all elements trigger to configure in the Google Tag Manager account

We’ll set the trigger to fire on Some Clicks. Configure the conditions as Click Text contains Add to cart

Save the trigger configuration. 

Configuring an add to cart trigger with custom firing conditions for some clicks on Google Tag Manager

We can now attach this trigger rule to our marketing Tags for tracking purposes. 

Let’s say we want to configure this trigger rule into our Facebook account. So let’s go to Tags → New and create a new Tag to configure this trigger. 

Creating a new Tag from the Google Tag Manager account

Add an appropriate name to the Tag. 

Similarly to a trigger, we also have various types for a Tag template. Let’s choose the Facebook Pixel as the Tag type. 

Choosing a Facebook Pixel type Tag configuration from Google Tag Manager

You’ll need to configure your Pixel ID by going to the Settings section of the Facebook Business Manager account. 

Accessing the Facebook Pixel ID from the settings section of the Facebook Pixel account

Paste the Facebook Pixel ID to the Tag. As the event type, let’s choose AddToCart under the Standard category. 

Configuring the Facebook Pixel ID and the AddToCart event to a Tag in Google Tag Manager

Finally, we’ll configure our trigger. We’ll choose click – Add to cart as our trigger type. 

Once done, click Save

Configuring an add to cart trigger for the Facebook add to cart Tag in GTM

So that’s how we install our Tags and triggers! 

However, this version isn’t live yet. We can still edit and debug it in the Preview mode as we learned earlier. 

Let’s connect our website in the preview mode of our browser to verify our Tag implementation. 

We’ll choose a product on our website and click on Add to cart

Selecting the Add to cart option on the website to generate data for tracking user movements

This information is tracked in our Google Tag Assistant account, as well. 

Under the event of Click, our Facebook Add to cart Tag is fired. 

Verifying the fired Tags from the Google Tag Manager browser extension

Let’s also test our Tag before we make it live on our website! 

On the Facebook Business Manager, navigate to Test Events → Open Website

Entering the preview mode from the Test Events section of the Facebook Pixel account

This leads us to our demo website.

Reload the page and choose an item for the Add to cart event. 

This event will definitely be monitored by Google Tag Assistant. However, we want to verify the results with Facebook Business Manager, as well. 

Under Test Events, we’ll find our fired Tag for Add to cart

Verifying the fired Tags from the Test Events section of the Facebook Pixel account

Since the Tag is working as expected, we can publish this version on our website. It will deploy our tracking to the website for all our audiences. 

Remember: The best practice is to first create the Tags, and then verify them in debug mode before making any changes to the live website. 

Click on Submit to submit the current version of tracking. 

Submitting the current version of the Tags to publish it and make it live for other users

You can add a name to the version. Click on Publish once done. 

Publishing the current version of the Tags to make it live for the audience

Henceforth, all the users who click on the Add to cart button will be tracked through our implementation of the Facebook Pixel. 

One of the advantages of this setup is that you can always navigate back to your previous versions of tracking and restore them. 

Analyzing the live published version of the website from the Google Tag Manager account

So that was our quick lesson on how Google Tag Manager works. If you want to test your knowledge on this lesson, check out this Lesson 1 Quiz

This was just an overview to help you familiarize yourself with the tool to start your own tracking system. 

There is much more to Google Tag Manager. One of the major benefits is installing it on our website. 

How to Install Google Tag Manager onto Your Website

Let’s first open our Google Tag Manager account. 

First-time users will need to sign in to the account. You can sign in with any kind of Google account including your YouTube or Gmail account. 

In case you don’t have a Google account, you can create one instantly. 

We have a new demo account for the purpose of this lesson. Let’s click on Create Account, as this is the first time login with this account. 

Creating a new account for accessing Google Tag Manager

Google Tag Manager is made with accounts and containers. 

Adding account information to create a new Google account for Google Tag Manager

So, any account is simply a collection of various containers

Containers are the snippets that are installed onto our website. 

It is a good practice to use your company name as your Account Name in GTM. Next, you can add your country name. This is important for privacy reasons. 

You can also choose to share this information anonymously with Google. 

Configuring Data to a new account on Google Tag Manager

Let’s move on to containers. 

We’ll add our website URL as the Container Name in this case. It isn’t necessary to use the URL for the container name, but we have chosen our own conventional method. 

If you have multiple accounts or containers, it is always good to have your own naming convention systems for those accounts. 

Next, we’ll choose the Target platform. 

Ideally, you can install Google Tag Manager on Web, iOS, Android, AMP, and Server-side platforms. 

However, we’ll choose the Web platform for this tutorial. 

Click on Create once done. 

Creating the container set up for a new Google Tag Manager account

You’ll receive the terms of service agreement once it configures your information.

Read the agreement once, click the acceptance tick, and click on Yes if you wish to proceed. 

Accepting the terms to create a new GTM account

With this, we have set up the account portion of Google Tag Manager. 

Our next step will be to install the GTM snippets into our website scripts. This is very important for us to deploy codes through Google Tag Manager. 

Click on your GTM ID to access your GTM snippets. 

Accessing Google Tag Manager code snippets from GTM ID

You can also access those snippets through Admin → Install Google Tag Manager.

Accessing code snippets from Admin section of Google Analytics account

Let’s now configure these codes onto our website! 

Installing GTM Snippets Onto the Website

Snippets are extremely important for us to deploy codes through Google Tag Manager. 

These scripts will be the last codes we install onto our account, as henceforth, we’ll deploy all our Tags through the Google Tag Manager. 

There are two different types of codes in this script. One code is placed in the head section of the script, while the second code is placed in the body section of the script. 

Accessing the GTM code snippets for adding to the website script

We have a demo website for illustration purposes. Our demo website runs on the CMS WordPress setup.

Although WordPress is a widely accepted form of CMS, there are other CMS tools. Therefore, the installation process may vary accordingly.

For example, in WordPress, we can use the theme files, or plugin into our functions PHP, or install a plugin to configure Google Tag Manager to the website. 

But once our installation is complete, the outcome will be the same for all of the setups. 

Let’s open our website, and right-click on it to open View Page Source

Accessing the source codes of the website page

You’ll notice that the page script contains a header code for GTM at the beginning of the code. 

Analyzing the GTM code snippets from the website page source

Also, in the central region, you’ll find the body code for GTM. 

Analyzing the GTM body code snippets from the website source codes

There are various methods for executing this installation, but we’ll choose to add the codes to our functions PHP, as this is the most accessible method for all WordPress websites.

Login to the backend section of your website, and navigate to Appearances → Theme Editor.

Accessing the theme editor from the Admin section of the website backend section

You can choose the theme as Storefront Child Theme. This way, any updates on our main theme won’t overwrite the edits in this section.

Go to the Theme Header file. This is where we’ll add our changes to the script.

Accessing the theme header from the theme files section of the website backend channel

Let’s first copy our header code. 

We’ll place the header code below the opening head Tag. This should be as high in the code as possible. 

Configuring the GTM header code on the website source snippet

Next, we’ll copy the body code and place it below the opening body Tag. Click on the Update File after configuring the codes. 

Configuring the GTM body code on the website source snippet

Let’s inspect the HTML after installing the codes. 

Reload the website page, and again open the View Page Source section. 

Checking the page source codes of the website

If the configuration is correct, you’ll see the GTM code at the beginning of the script. 

Analyzing the page source codes of the website

Similarly, you’ll also see the GTM body code in the central section of the script. 

Analyzing the page source codes of the website

Let’s also verify the results of the script. 

Open the Google Tag Assistant Legacy plugin from your browser. You can sign in with the same account as you use for GTM. 

If the installation is correct, you’ll see Google Tag Manager on your plugin. Click on it to verify more details. 

Verifying the Google Tag Manager Tag analysis from the Tag Assistant legacy extension

If you see GTM in yellow color, it means the installation is incomplete. 

You’ll need to publish a version from GTM in order to make this into a green color. This is because although we have GTM installed on our browser, currently it’s not getting any data.

Analyzing the Google Tag Manager Tag analysis from the Tag Assistant legacy extension

Let’s solve this by going into Workspace and clicking on Submit to publish a version. 

Submitting a current version of the website to make it live for the users

This is just our initialization version. So we’re not adding any Tags or triggers to the setup, but we’re just verifying that our container is in ready-to-use condition. 

Add a Name to the version, and click on Publish

Publishing a current version of the website to make it live for the users

Let’s reload our website and verify the results in Google Tag Assistant Legacy. If the installation was successful, you’ll see that Google Tag Manager is now seen in green.

Analyzing the Google Tag Manager Tag analysis from the Tag Assistant legacy extension

Once we’re able to verify the results of Google Tag Manager from the Google Tag Assistant Legacy plugin, our next step will be to use the preview mode on our browser. 

This will put our browser into a special mode in which only our browser will be able to track the changes we deploy in the Google Tag Manager account. 

Click on Preview to enter the preview mode. 

Entering the preview mode of the website to verify changes made through Google Tag Manager

Add your website URL and click on Start

Entering the preview mode of the website to verify changes made through Google Tag Manager

This will open our website in a special mode in the new tab. 

Let’s navigate any page on our website. The URL changes for different pages. 

Analyzing the URL of the website to verify URL tracking

The Google Tag Assistant account will monitor these changes for us.