5,810 total views, 9 views today
Summary: Step-by-step instructions for how to switch your website over to Google Tag Manager without losing any of your existing Google Analytics data.
Using Google Tag Manager to manage your Google Analytics and other tags is great – once you start using it you’ll be so glad you made the switch! This post is available in text and video format below
I always install Google Tag Manager on a website and use that to handle Google Analytics rather than adding Google Analytics directly.
The reason I use Google Tag Manager instead of just using Google Analytics is that Google Tag Manager makes it really easy to also track website events in Google Analytics and to send conversions to your advertising platforms. This lets you track if people are clicking specific links, submitting your contact forms, adding products to their cart etc.
There is so much that can be done with Google Tag Manager but I’ll save that for dedicated posts.
In this post I will cut straight to the “how to” aspect of the specific steps involved in creating a Google Analytics tag in Google Tag Manager. You can follow along and easily install Google Tag Manager on your own website.
In this example I’ll also show you how to set your Google Analytics tracking code as a Settings variable in Google Tag Manager so that you can refer to the tracking code whenever you need without having to look it up each time.
Step 1: Create an Account
If you don’t yet have a Google Tag Manager account, then set one up at https://tagmanager.google.com. To do that you need to click on CREATE ACCOUNT.
Enter the Account Name, which is the name of your business
Select the Country
Tick the Share data anonymously with Google and others if needed. – This enables Google to have your data benchmarked.
Step 2: Create a Google Tag Manager Container
Next up, create a container for your Google Tag Manager tag. This will be named according to your website name, e.g. www.mysite.com. You will also need to choose a container type. Here are the container type options:
- Web is the container to choose for a website.
- IOS and Android are for phone apps
- AMP is a Google AMP page
In the majority of cases we will be selecting ‘Web’.
Click on CREATE.
Step 3: Accept the Terms of Service and Data Processing Terms
You’ll need to accept the Terms of Service agreement and the Data Processing Terms for GDPR before Google will let you complete your new Google Tag Manager container.
Step 4: Get the Google Tag Manager code to put on your website
Once you’ve agreed to the terms of service, Google will create two snippets of code that need to be installed on your website. These are installed in the head section of your website and the top of the body section of your website respectively. Most website themes should give you a way to add these snippets of code as part of the theme itself, but if not there are plugins you can use. You are most likely already using your theme or a plugin to deploy the Google Analytics tag, so deploy these using the same way.
Here’s what the tag code snippets look like.
Step 5: Don’t forget to grant access to other users
If you need to grant access to other users, don’t forget to do that straight away! Always make sure the website owner is an admin user if you are setting it up for someone else.
Go to ADMIN and click User Management under account. Click the Add button to add a user.
Enter the user’s Google email address into the Email text box. Btw, it doesn’t have to end in gmail.com if the user uses Google For Work with their own domain name on their Google account.
For a new admin user…
Set Account Permissions to Admin.
Set Container Permissions to Publish.
Click the Invite button to invite the user.
Have you added the code to your website yet?
Once you have got the tags on your website it’s time to set up Google Analytics in your Google Tag Manager.
Step 6: Add Your Google Analytics Tag
Go to the Google Tag Manager container that has been set up for the website.
Go to WORKSPACE and click on ADD A NEW TAG
Name the tag Google Analytics.
Step 7: Configure your Google Analytics Tag
It’s now time to configure your Google Analytics tag in Google Tag Manager. Click anywhere in the Tag Configuration field.
Select Universal Analytics tag type
Select Page View from the Track Type drop-down menu
Step 8: Time to create your Google Analytics Settings Variable.
Activate Google Analytics Settings drop-down menu and select New Variable.
Now you’ll need to go to Google Analytics for a minute. It is at https://analytics.google.com. Go to Property Settings in your Google Analytics and copy your Tracking Id from the page.
IMPORTANT NOTE: Make sure that you pick the correct Google Analytics account and the correct Google Analytics property! If you have more than one, do make sure you select the one that has been collecting data up until now. If you choose the wrong one then you could lose your historical data.
Type a name into the space at the top. It defaults to Untitled. Paste in the Google Analytics Tracking Id as variable name for your new Settings variable on Google Tag Manager. Alternatively you can call it Google Analytics Settings or something similar, but I like to use the tracking ID so that I can easily identify the ID if an account has multiple instances of Google Analytics running.
And in the Tracking ID text box. Then click SAVE! You can now use this tracking code Settings variable any time you need it.
Keep your cookie domain set to “auto” unless you have special Google Analytics settings. Without this setting, Google Analytics will not work over subdomains.
Step 9: Almost there! Time to create your Google Analytics Tag Trigger.
Click on the Triggering field.
Select All Pages trigger. This causes Google Analytics to activate on every page of your website, as soon as a user ‘views’ the page.
Save the tag!
Step 10: Test your Google Analytics Tag
Your tag is complete! You are ready to publish Google Analytics to your website via Google Tag Manager. Before you do though, it is very important to test it out. To test your Google Analytics tag, click the ‘Preview’ button. The Preview button moves your Google Analytics tag into a state whereby if you visit your own website from your current browser it will act as though your Google Analytics tag is published. However no other visitors can trigger your tag until it is published.
This is what it will look like when you move into Preview mode:
Go to your website from within the same browser and the Google Tag Manager preview app should pop up at the bottom of your screen. If your tag is working then you should see the message ‘Google Analytics Universal Analytics – Fired 1 time(s)’. If you don’t get this message, check that the Google Tag Manager tracking code has been correctly added to your website and that the tracking code value matches the tracking code for your Google Tag Manager web container.
Once you are satisfied that the Google Analytics tag is firing, you can disable preview mode and then publish your tag. Hold off a minute on publishing though.
Step 11: Remove your old Google Analytics code or plugin from the website
At this point, if you don’t already have Google Analytics on your website then you can just go ahead and click the Publish button. However, since this blog post is about how to switch over from Google Analytics to Google Tag Manager I’m assuming you already have Google Analytics installed. In order to switch over to Google Tag Manager you need to remove the Google Analytics tag when you publish the Google Tag Manager tag. It doesn’t much matter which order you do this, but you’ll want to do them as close together as possible so that you don’t experience much time without any tracking, or much time with both tags tracking. I generally remove Google Analytics first and then immediately publish Google Tag Manager, because I personally believe that a short period with no tracking is better than ending up with double tracking.
Step 12: Submit and Public Google Tag Manager
Once you’re back in Google Tag Manager, click SUBMIT.
Before you can finish publishing, Google Tag Manager asks you to name this revision and describe what the change is, so that if you want to roll back you can do so easily. Type in a suitable name and description that you will understand. I usually type in a timestamp as the version name. It doesn’t matter what you pick. Click the ‘PUBLISH‘ button to finalize this step.
Step 13: Confirm the Tag is published to your website
IMPORTANT NOTE! Now that your tag is published it should all be working fine, but you do need to test it again. To double check that everything is setup correctly, go to http://www.gachecker.com and check that there is a tick under Google Tag Manager. I usually also right click on the website (after refreshing) and select view source. I manually search for the Google Tag Manager tracking code and the Google Analytics tracking code. The Tag Manager code should be present and the Google Analytics code not present.
Step 14: Check Real-Time View in Google Analytics – you should have data coming through
Now your Google Analytics tag is live on your website. You can test this by navigating to your website again and then going to your Google Analytics ‘All Website Data’ view (or any view that doesn’t filter out your own IP address). If you click on the Real-Time overview in the reports you will see that data is now coming through. You are done!
If you are responsible for digital marketing you will need to know how to collect and read numbers. This will improve your results and help you to generate more revenue from your online presence.
If you would like even better digital marketing results then I guarantee that I can help you with that. Getting started is simple – just subscribe to my free web analytics training by filling out the form below.