0405123696 petra@web-data-analytics.com

 2,853 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.

Adding Google Analytics to Google Tag Manager

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.

Adding Google Analytics to Google Tag Manager


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.

Adding Google Analytics to Google Tag Manager

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.

Adding Google Analytics to Google Tag Manager


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.

One trick if you can’t get the body code installed is to add it into the website footer as this is typically repeated on every page. If you are still unable to get the body code installed at this stage, your Google Tag Manager will work fine in the majority of cases with only the head code. The body code is used when your website is viewed on a device in which javascript is unavailable.

Here’s what the tag code snippets look like.

Adding Google Analytics to Google Tag Manager

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.

Adding Google Analytics to Google Tag Manager

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 Done.

Adding Google Analytics to Google Tag Manager

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

Adding Google Analytics to Google Tag Manager

Name the tag Google Analytics.

Adding Google Analytics to Google Tag Manager

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.

Adding Google Analytics to Google Tag Manager

Select Universal Analytics tag type

Select Universal Analytics tag type

Select Page View from the Track Type drop-down menu

Adding Google Analytics to Google Tag Manager

Step 8: Time to create your Google Analytics Settings Variable.

Activate Google Analytics Settings drop-down menu and select New Variable​​​​.

Adding Google Analytics to Google Tag Manager

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.

Adding Google Analytics to Google Tag Manager

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.

Adding Google Analytics to Google Tag Manager

And in the Tracking ID text box. Then click SAVE! You can now use this tracking code Settings variable any time you need it.Adding Google Analytics to Google Tag Manager

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.

Adding Google Analytics to Google Tag Manager

Select All Pages trigger. This causes Google Analytics to activate on every page of your website, as soon as a user ‘views’ the page.

Adding Google Analytics to Google Tag Manager

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:

Adding Google Analytics to Google Tag Manager

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.

Adding Google Analytics to Google Tag Manager


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.

To remove Google Analytics you need to remove the Google Analytics snippet of javascript code from your website. It will be located within the head section on every page of your website and was most likely installed via a theme or a plugin. You might have found it when you installed the snippets of Google Tag Manager code page at step 3. When you remove your Google Analytics code from the head section of your website you won’t lose any of your existing Google Analytics data. You won’t see any new data come into Google Analytics however until you publish Google Tag Manager. Go ahead and remove your Google Analytics code from your website and then come back to Google Tag Manager.

Step 12: Submit and Public Google Tag Manager

Once you’re back in Google Tag Manager, click SUBMIT.

Adding Google Analytics to Google Tag Manager

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.

Adding Google Analytics to Google Tag Manager

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!

Adding Google Analytics to Google Tag Manager

What’s next?

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.

brett leggett

Hi Petra, Hope you are well, I checked out the Google Analytics and all I can say is AWESOME. You have essentially doubled her revenue in a month and the Google Ads seem to be popping off!

Brett Leggett Brett Leggett ✪ eCommerce Growth Specialist Ecommerce Google Ads April 23, 2020

Michelle Bridger

Petra's detailed reports and her personal assistance has been helping us to know where to concentrate our efforts and even showed us technical issues we needed to fix. Our Audience Engagement Report identified several key interests of our buying audience. We tried targeting one of those interests and it brought in two sales almost immediately! I highly recommend working with Petra and accessing her brilliance to scale your business.

Michelle Bridger Michelle Bridger, Facebook Advertising Specialist Ecommerce Google Tag Manager, Google Analytics & Google Data Studio Configuration April 23, 2020

Ian Gale - Sleepwise Clinic

Petra was instrumental in pulling all our clinic's web analytics into one easy to read, dynamic report that's accessible to me at any time, and works with our EXACT booking system.

This has allowed me to see, at a glance, what marketing initiatives are working, need tweaking, or changing altogether, saving me both time and money. I can't recommend her or her analytic services enough.

Ian Gale SleepWise Clinic Analytics Dashboard August 1, 2018

david clayton myomasters

Your attention to detail is beyond what I had expected. The detail of the data is incredible. The best part though was to learn the profile demographic - which is very different to whom I think I've been trying to target through social.

David Clayton Director, Myomasters Massage Health Clinic Google Ads April 23, 2020

Kiley Hay Baby Carriers Australia

I have been working with Petra for over a year now after changing from a much larger digital marketing provider and I could not be more pleased with the service and results my business is achieving.

With my previous providers I felt disconnected with limited communication. Petra on the other hand provides me with knowledge and information in a language I can understand that helps me make informed decisions not just about digital marketing but also my e-commerce business as a whole.

Petra has helped me navigate seasonal drops in trade creating a strategy that helped us grow and establish a healthy position in the market. It is an absolute joy to work with someone who loves what they do. I have complete confidence in recommending Petra to anyone considering e-commerce digital marketing, she is efficient, trusted and a true professional.

Kiley Hay CEO of Baby Carriers Australia Ecommerce Google Ads April 23, 2020