Beginner’s Guide To Google Tag Manager – Part 2
I am assuming you have gone through the Part -1 of this beginner’s guide series and created your GTM accounts. So, let us dive into part -2
In this blog post, I shall walk you through
- How to integrate GTM into your website. Both Manually and on a wordpress website.
- The complete GTM account explaining the terminology with screenshots
- Creating Tags, Triggers and Variables with examples.
First, Integrating GTM into your website:
GTM gives you <script> and <noscript> code to place it on your website. To access that, you can either go to admin and click on the “Install Google Tag Manager” in the container menu.
Or go to your workspace, on the top you will find your container ID formatted as “GTM-XXXXXX”. Click on it.
It shows you code in two boxes to place on your website.
Setting up GTM on your website Manually:
Do follow the instructions to place on your website. When you placing this manually, make sure you do place the code in <head> and <body> as instructed. Once you work with this code and that is it. You no need to go back to editing code for any kind of tags.
Setting up GTM on WordPress website:
If you are working on a wordpress site and need to place this GTM code, there are lot of plugins to use.
But before that, first check if your theme gives you the flexibility to simply add tags in the website <head> and <body> tags.
If not, you can also access your website code through editor and add the code there.
For this, go to Appearance —> Editor and look for header.php
Open header.php and add the <script> and <noscript> code according to the instructions given by GTM.
Now, let us look at the different sections of GTM. Starting with Admin.
Admin: This is the place where you can access all your account settings, container settings, account activity, user management, approvals…etc
User Permissions: You can delegate access to other users (your team) at both the account and container level. At container level, you can grant them permission to read, edit, approve and publish. At the account level, the two new user permissions you can grant are user or admin.Accont Level User Management
Container Level User Management
Account Activity: It displays the detailed history of activities/actions done in the account.
Account Settings: Here you can choose to change the name or delete the account. When the account is deleted, the containers this account has will also get deleted. When you choose to change the name, name gets changed but the account ID remains same.
You can also give 2-step login verification for certain operations. When enabled, 2-Step Verification is required in order for a user to:
- create or modify custom HTML tags
- modify user settings
Container Activity: It is similar to account activity but actions/activities performed in that particular container only will be displayed.
Container Settings: Similar to account settings, you can change the name or delete the container. Only that particular container in the account gets deleted.
External Account Links & Approval Queue: These features are only for flood light set up only. This is for you if you are using double click flood light tool and want to integrate to GTM.
Environments: This feature is related to server environments. To put it in simple terms it is for companies who have production, staging, development environments in their servers. They might want to test the container changes in their test environments before pushing it live. So, this is not for a non-techie. If you are a techie reading this article and want to know more – you will get more information here.
Coming out of Admin, there is Versions in the main menu.
Versions: Google defines it as “A version is essentially a snapshot of a container”. Each time you perform some actions in your container can be saved as a version even without publishing. That means, you can save it and come back again later to continue your actions on that version. Or even leave it for approval before publishing. You can’t edit a version. But you can restore it as the new version and work on it.
Different actions you can perform on a version are
If you are still confused about versions. Nothing to worry. You will get to know it better as you start working on GTM.
Workspace: Google defines workspace as “In Google Tag Manager, workspaces enable you to create multiple and different sets of changes to your container”. To put it in simple terms, let us call a workspace as a container draft.
Each container can have one default workspace and two custom workspaces. Each workspace is independent of other. Out of the three container drafts,(workspaces) only one will be live. That means these workspaces are created to help you
- While working with a team. So, that each team member will have the ability to independently work on the container and test the configurations without the fear of accidently someone publishing them.
- When you want to test something and don’t want to create multiple versions of it in existing container draft, also to avoid accidently publishing. It reduces the complexity of container version history.
NOTE: If you are the only person working on your container, avoid creating multiple workspaces. It is to reduce the complexity of merging the workspaces while publishing.
If you are a team working simultaneously on the same container and need to understand managing workspaces better, – Here is the resource from Google I recommend.
Now entering into the crucial part of GTM, creating tags, triggers and variables. I will explain you what Tags, Triggers and Variable are along with live examples on creating them.
Another wonderful thing about GTM is we can preview and test if the tags we created are working or not before publishing them.
These examples will surely help you understand them and give you a way to explore more, and build more complex tags to use GTM to its best.
To start off the first Tag I am taking Google Analytics tags. Why because, it is the most used and must have for every application.
What is a Tag here? As we discussed in the previous blog post, it is a piece of code given by a third party service to collect the data from your website.
Here in this example, Tag is the code given by Google Analytics to place it on the website.
And as I told earlier, GTM uses triggers and variables to control how and when the tags fire. So, setting up a tag only completes when you tell GTM the Trigger point for the Tag. That is when should the Tag Trigger/fire.
This is the Workspace Overview Tab Click on any of the link to create a Tag
Creating a Tag:
- Give title for your tag
- Click on create tag.
- Click on create trigger.
- And Save.
In this example: To create a tag for Google Analytics.
- Open Tag interface.
- Give the title as Universal Analytics
- Click on “Tag Configuration” and the list opens. It has popular Tags like Google analytics and adwords predefined. And when you scroll down, you will see custom tag options to create tags which are not listed here. (Ex: Facebook pixel) Will show you creating custom Tag in next example.
- Select Universal Analytics” from the list.
- It will ask you to set up “Track Type” and a “variable” to complete the tag.
- Select “page views” in Track Type. That means we are creating a Tag for Google analytics to page views.
- Since we haven’t talked about Variables yet. Click the check box for “Enable overriding settings in this tag” and it will ask you for “Tracking ID”.
- Assuming you already created your Google Analytics account for the same website/product you have created this GTM account. Pick the “Tracking ID” from your Google Analytics account and put it here.
- Now scroll down to Triggering and click on it.
- If it already shows “All Pages” click on it, it gets added. Else click on plus symbol on top right corner and it will open trigger configuration. Click an it opens a lit of triggers like in Tags.
- There select “page views” and it will ask you further to choose “All pages” or “Some pages”. Select all pages. That means, you are telling GTM to fire “Universal Analytics” tag on every page.
That means, when a visitor visits any page of your website, this tag fires and sends information to “Google Analytics” where the reports will generate.
Triggers: A trigger is a condition that evaluates to either true or false at runtime. Triggers attached to a tag govern when the tag is fired or not fired.
To understand better,
- A Tag must have atleast one Trigger attached to fire.
- A Trigger tells the Tag when to fire.
- A Trigger evaluates the trigger condition during runtime and lets the associated Tag to fire or not fire.
- There are two types of triggers pre-defined built-in Triggers and a “Custom Event” Trigger.
- Also, you can customize the pre-defined built-in Triggers as well.
- You can have multiple Triggers to a Tag. Also you can give an exception.
Once you created your tags and before submitting them to publish, you can check if they are working.
For this, GTM provides preview option. You need to click on preview from your workspace dashboard and open your website in the same browser.Click on preview and this notification appears.
Now open your website in the same browser(next tab) and you will see the list of tags fired on that page. Browse through the pages to see “Universal Analytics” tag firing on every page.
Note: To cross check if data is reported in your Google Analytics. Keep these two tabs open and go Real time reports in your Google Analytics to see the active pages visited.
Now, let us look into variables.
Google defines Variables as,
Variables: Variables are name-value pairs for which the value is populated during runtime.
To understand better,
In programming terms, Variable is a storage location in the memory which has a name and a value.
What that means in GTM is also similar. Let us call it a function to which we give a name and a value. These are used in Tags and Triggers.
- GTM provides pre-defined variables for most common activities.
- GTM also gives users the flexibility to create their own custom variables. It calls them user-defined variables.
To access these variables, click on variables in left menu
To understand its usecase, I’ll explain it with a simple example:
In example 1 we shall use built-in variable.
- Go to Triggers in Left Menu à and click on New.
- Choose Page View Trigger.
- Select “Some Page Views”. This is to specify the condition in Trigger.
- There you will see list of variables in the dropdown. The list will have the variables you selected.
- Select Page Url and filter it and give a value.
You can use this Trigger to fire the Universal Analytics tag to see page views came only to the thankyou page.
Example 2, we shall see how to create a new user-defined variable.
Let us create variable for Universal Analytics Tracking code. So, when ever we create a tag to fire Universal Analytics, we can use this variable.
- Go to Variables in the left Menu —> Click on New under User-Defined Variables
- Select “Google Analytics Settings” from the list
- Give your universal analytics tracking code there. Leave the cookie domain as auto.
- Save it and you can see it under User-Defined variables list.
- Go to Tags from the left menu and create a new Tag.
- Select Universal Analytics
- And you can proceed creating Tag and Trigger.
The one thing which makes GTM more flexible is the Variables.
Built-in variables are pre-defined and cannot be customized.
Google Tag Manager has number of built-in variables and they are different for each type of container. (Web/IOS/Android/AMP)
With this the beginner guide to GTM series is done. But I will not stop writing about GTM and Google Analytics.
In the next GTM blog I will walk you through setting up the necessary tags and triggers for a website. That means, what are the important Tags a website needs so that you can track and analyse a lot of stuff. Stay tuned! I will also go live on my Facebook page to discuss this beginner series.