Are you looking for a quick and easy way to start using Google Analytics through Google Tag Manager?
🚨 Note: Since Google Analytics will be sunsetted on July 2023, we recommend starting the GA4 migration process.
In this guide, we’ll learn the step-by-step procedure to install Google Analytics tracking on your website with the help of Google Tag Manager.
An overview of what we’ll cover:
- Create a Google Analytics Tag
- Configure a Google Analytics Settings Variable
- Attach a trigger to your Tag
- Test your Google Analytics Tag
- Publish GTM changes to your live site
- Frequently asked questions
So let’s jump right into it!
Create a Google Analytics Tag
We’ll start this tutorial with a demo shop with Google Tag Manager installed. If you don’t already have it, we suggest installing Google Tag Manager as the first step.
Ensure that you have installed Google Tag Manager correctly by clicking on GTM’s Preview mode on your website.
This version will be only for the browser we clicked on to Preview from the Google Tag Manager account.
It will also show all the different Tags and triggers set up for the website from the Google Tag Manager account. Currently, we don’t have any Tags running.
If the preview and debug console loads successfully, then you’re ready to begin.
The first step in building your Google Analytics Tag is to access the Tracking ID from the Google Analytics account for your website.
Click on the Admin section next to the wheel icon in the Google Analytics interface.
Under this Admin section, navigate to Property → Tracking Info → Tracking Code.
You’ll see that the Tracking Code will deploy on all the pages of your website for Google Analytics to function correctly.
We will not use the Global Site Tag for this guide. Global Site Tag code is an all-in-one code that will directly deploy Google Analytics tracking on our website.
Since we’ll be deploying everything via Google Tag Manager, we just need to copy the Tracking ID instead of the code.
Once the Tracking ID is copied, we’ll come back to Google Tag Manager.
We’ll need to create a new Tag on Google Tag Manager to configure the tracking ID.
In your Google Tag Manager account, you can use the Tracking ID to create a new Tag.
Open a new Tag with Google Analytics: Universal Analytics as the Tag type.
Google Tag Manager provides different tracking templates so we don’t have to manually implement any kind of code. We just choose a template from all the options.
Once we choose a template, it will give us some fields to fill out. The first field is the Track Type. What kind of interaction do we want to send over?
In our case, it would be Pageview tracking that we want to deploy on all the pages.
Next, we’ll choose our Google Analytics Setting Variable. Variables will contain our tracking ID.
Configure a Google Analytics Settings Variable
In case you already have any variables set up in the past, then you can use them. However, we’ll create a new Google Analytics Settings Variable for this Tag.
This is where we will need our Tracking ID. But we don’t have anything available here yet, so we’ll select New Variable.
On the variable, we’ll add the Tracking ID that we copied. We won’t make any changes to any other fields.
Next, we’ll add a Name to the Variable. A good practice is to add the tracking ID itself as the name.
This way, if you have more than one account, you can easily access tracking ID variables for each account.
Once done, click on Save.
Once the variable is set up, we’ll also add a trigger to deploy the Tag.
Attach a Trigger to your Tag
A trigger defines when you want to deploy the Tag. You can choose to deploy it on all pages or only on certain pages.
In this case, we’ll choose the pre-defined trigger named All Pages.
Hence, we’ve configured an All Pages trigger to a Page View Tag. So, we’ll track whenever a user views any of our pages on the website.
Once done, you can give a Name to the Tag, and click on Save.
Before we go any further, it’s best practice to test this implementation to make sure everything is working correctly.
Test Your Tag Implementation
From your Google Tag Manager account, enter Preview mode.
We’ll refresh Google Tag Manager and our website so our Tag gets uploaded.
After your website reloads, you’ll be able to see the Tag in the Tag Manager console.
If the installation is done correctly, our Pageview – All Pages Tag will fire on the website.
Additionally, you can also open any random page on your website to make sure that the Tag fires on all pages.
At this point, we’ve already fired the Tag. However, we also need to make sure that this information is carried along to our Google Analytics account.
There are two easy ways to make sure that Google Analytics is receiving data from this Tag.
The first step is to use an extension in Chrome called the Tag Assistant Legacy by Google. We can see under the Tag Assistant Legacy extension which tags have fired.
In this case, the extension shows that Google Tag Manager and Google Analytics tracking codes have been fired on this page.
If we click on the Pageview Requests, we see that the Pageview details are transmitted.
Also, some users might see the Non-standard implementation option in blue instead of green. That’s fine.
Google Tag Assistant simply shows the information that was sent over to Google Analytics or any other tools.
Therefore, we’ll also be able to see the same information on the Google Analytics interface.
Let’s open our Google Analytics account.
On the home screen, we’ll open Real-time → Overview.
Whenever a user opens a page or any other interactions take place, we’ll get the results on this page.
🚨 Note: If you’re using Google Analytics 4, the process will take longer since GA4 batches data.
You can also try clicking on other pages on your website to generate multiple results on the Google Analytics interface.
Your page path for the Active Page will also change accordingly.
🚨 Note: If you see pageviews appearing twice in your reports when you should only see one, check for other Google Analytics implementations.
You may have a Gtag or other implementation hard-coded into your website, which would result in double-tracking and bad data.
Make sure to check your website theme files for unwanted code or extra tracking implementations.
In case you aren’t able to see any visuals on the Overview page on your Google Analytics account, it might be because your account is fairly new to report any results.
There may also be problems with the implementation of the Tag or tracking ID of Google Analytics.
But it may also be due to any filters you may have added to your Google Analytics interface for better optimization.
Moreover, our installation isn’t complete yet. We still need to publish the changes we made to the website in the preview mode so our Tags become live for other users.
Publish GTM Changes to Your Live Site
To make this implementation live, you need to publish a version in Google Tag Manager. Click on the Submit button.
You can add a Name to the version, and click on Publish.
You can also give a Version Description that describes the changes made in this update.
Each time you publish, you’ll create a new version of your website. The number of the version will appear on the screen along with the name of the version.
So, that’s how you can install Google Analytics with Google Tag Manager.
Frequently Asked Questions
Here is one frequently asked question related to implementations on Google Tag Manager.
What can I do with any implementation done beforehand?
If you have any plugins installed on your website or your WordPress accounts, or if you have GTag or Google Analytics installed in your theme files of the website, we recommend you uninstall them.
Currently, we’re deploying our tracking through Google Tag Manager. We won’t necessarily need the previous implementation anymore.
If you have both the implementations intact, then it might fire the Google Analytics Tag twice.
In this case, you’ll get double results for your website tracking, and such an issue can also hamper your Google Analytics reports.
Therefore, we recommend you remove any hard-coded implementation of GTag or Google Analytics tracking script.
It’s recommended to deploy everything through Google Tag Manager.
This is a simple method to configure Google Analytics with Google Tag Manager. With this, you can start tracking your pageviews without writing any code.
This is recommended because instead of adding various codes to monitor each type of tracking on our website, we can do it directly through Google Tag Manager.
Additionally, once you start analyzing the data through Google Analytics, you can also learn to set up goals in Google Analytics for better website performance.
What did you track with the method from this guide? How did you use this data to optimize your website goals and campaigns? Let us know in the comments below!