How to Migrate To Google Tag Manager For Google Analytics

How to Migrate To Google Tag Manager For Google Analytics

Adding element IDs helps get your website Google Tag Manager ready

Google Tag Manager is a powerful free software platform. It enables you to automatically install code (called tags) for many digital marketing solutions on your website. This minimises the number of marketing tags you need to install on your website because GTM only injects them onto your site when required according to pre-set rules

Despite the clear benefits of using Google Tag Manager, many small and even medium sized organisations don’t use a tag management system for analytics and marketing solutions. Instead, they rely on code, such as for Google Analytics, to be hard-coded onto their site. This is inefficient and limits your ability to enhance your web analytics and conversion rate optimisation capabilities. 

Why should you migrate to Google Tag Manager? 

 So, what are the main benefits of migrating to Google Tag Manager?

  • Agile deployment of tracking codes without the need for developer resource. 
  • Ability to create new tags within GTM and so there is often no need to make any changes on the website.
  • Debug tools included in the Preview mode of GTM. 
  • Ability to export container templates to reuse tags in other containers. 
  • Built-in tags for a range of tracking tools, including GA, AdWords, remarketing and Hotjar. 
  • Ability to roll-back changes via versions. 
  • Workspaces allow you to work independently of other analysts without the risk of publishing changes created by another analyst.
  • Environments allow you to publish your tags to different website environments 
  • Manage all tags in one location and so there is no need to update tags on website as this can be completed in GTM.

How Do You Migrate to Google Tag Manager?

To migrate to Google Tag Manager just requires a bit of planning and a small amount of development resource. If you are replacing a basic implementation of Google Analytics, you can probably implement GTM without losing data from your hard-coded Google Analytics property. So, don’t delay, because once you migrate to Google Tag Manager you will wonder why you didn’t do it earlier

1. Create GTM Container: 

If you already have a Google registered email you can go straight to Google Tag Manager and create an account. It’s good practice to have a separate account for each organisation to ensure permissions can be managed independently by each company you might work for. You can then set up a container for each website you plan to migrate to Google Tag Manager.

Go to the Admin tab and select the ‘+’ icon in the top right-hand corner to create a new container. You can now give your container a suitable name to reflect the website name and select the type of platform you are going to track

Create Google Tag Manager container

 Click ‘Create’ and you will be taken to the page with the GTM script and instructions on it. Copy and paste the instructions, along with scripts for the head and body tags into a Word document. Give clear instructions about which environments you want the code to be implemented on as ideally you will want to test it in a pre-production website first. You can then share this with your developer. 

GTM script for implementation

It is possible to use GTM ‘Environments’ to configure which website environment to test new tags on. However, this requires a different code snippet for each environment. This complicates code updates as many organisations try to maintain a consistent code base throughout the release process. I prefer to use identical GTM script for all environments and use a Lookup table in GTM to direct data to the appropriate environment. This means you don’t have to maintain different scripts on each environment.

It’s really down to individual circumstances. If you have complex implementations in mind in secure parts of your site and want to publish and test in different environments, it may be more appropriate to use GTM Environments.

2. Create new Google Analytics Properties:

Before the GTM code has been implemented you need to create new Google Analytics properties to send the data to for your different environments. We will use a Lookup table in GTM to manage the data which I will explain later. Set up a Google Analytics property for production and any pre-production environments and add each Property ID to your tag plan.

I have created a template for a GTM tag plan which you can access here. This allows you to document all the different tools and their IDs in one place. There is also a tab for you to list each tag you create and to explain what they are used for. Keep this up-to-date so that you don’t have to rely on your memory to recall the nature of each tag.

Google Tag Manager tag plan

Create a separate view for testing so that you can configure filters and custom dimensions before you set up a reporting view. You should always test changes to your GA set up first before deploying to your reporting view. This will help avoid you losing data from incorrectly configured filters in your reporting view. 

3. Import Tags into Google Tag Manager Container: 

You can save a lot of time by importing a basic container with pre-configured tags. To help you with this process I have created a simple template container with pre-set tags. This includes tags for page views, click events with IDs, scroll depth, JavaScript errors, internal link clicks and 12 useful custom dimensions. You can download the examplesite.com container from the json file.

Google Tag Manager container template

To import the container, firstly create a new view and call it ‘Container Import’ or something similar. Then go to ‘Admin’ and select ‘Import Container’. Choose the ‘examplesite.com’ container file from your hard drive, and select your workspace. Then choose whether to overwrite or merge tags. If you have any existing tags in the container you should use the ‘Merge’ option to avoid overwriting anything you want to keep.

Import Google Tag Manager container

4. Configure Tags

Once you have imported the container you will need to edit some of the variables and triggers to adjust them for your website. Go the to ‘Variables’ and then ‘User-defined variables’. Select the ‘GA Tracking ID’ variable and click to ‘Edit’. This is a Lookup table and tells GTM which GA property relates to which website. 

GA Tracking ID

Here you will see the GA property IDs for the live (production) site and the UAT site. Replace the GA property IDs with the relevant ones for your website and add any additional environments and their GA property IDs. Save this variable. Remember to set the default value as the GA property ID for your live site.

Go to the ‘Triggers’ tab and select the ‘Click – Internal Links’ trigger. Edit the trigger to replace the examplesite.com URL with your site’s URL. Repeat this with the outbound links and download link types triggers.

GTM triggers which need the page path changing

5. Set up Custom Dimensions in Google Analytics

If you go back to the ‘Variables’ tab and select the ‘GA Settings Variable’ you will see 13 custom dimensions configured. Each of these has an index number which relates to the number allocated in the custom dimensions section of Google Analytics.

GA Settings Variable

To ensure GTM collects the data for each custom dimension go to your Google Analytics property for your live site. Go to the test view and select the cog for ‘Admin’. Below the ‘Property settings’ column select ‘Custom Definitions’ and then ‘Custom Dimensions’

Now select ‘+Custom Dimension’ to create each dimension outlined below. You don’t need to do any implementation as all but one of the relevant variables and tags have been configured in the examplesite.com container. Just make sure you set them up in an identical order so that each has the correct index number. Check the box to make each active except the User ID dimension.  Custom dimensions in Google Analtyics

The ‘User ID’ dimension is the only custom dimension that hasn’t been configured. This is because this normally comes from your CRM system and so would have to be implemented according to your own specifications and your cookie policy. For more details about all the custom dimensions go Simo’s blog – 13 Useful Custom Dimensions For Google Analytics.

 6. Install GTM Script:

Adding the script for GTM shouldn’t take a developer very long because most platforms have plugins for adding code. If you have a WordPress website you can use a plugin to paste the code in yourself.

GTM script should initially be put on pre-production environments so that you can fully test implementation and tags before you proceed to the live environment. If you are replacing a complex hard-coded Google Analytics implementation it is possible you will have conflicts with GTM and in such circumstances you would need to remove the hard-coded GA script and any hard-coded event scripts. Test it and see as sometimes you can get away with it. 

7. Test Tags:

If the GTM script has been properly implemented you should see the GTM panel appear at the bottom of your website page after you have refreshed the screen. Provided you are in the GTM ‘Preview’ mode and your pageview tag is correctly configured, you should see the Pageview tag fire each time you refresh the page.

GTM Preview mode

If the panel is completely white and blank you may have a conflict with browser extension or with the CSS of an element on your site. There is a great blog by Analyticsmania which explains how to fix Google Tag Manager’s preview and debug mode you should read if you find the preview panel not displaying.

Make sure you test all your tags in a pre-production environment. Also use your GA property for the same environment to check that GA is being sent the data and that all your custom dimensions are working. 

8. Test at each step of release process

It’s a good idea to check that the GTM script is working in each environment as it goes through the release process. This just confirms that nothing has changed to break or remove the script. Don’t assume it will continue to work as your GTM script can easily be broken if it is moved or other conflicting script is added to the code base.

9. Compare Data to GA Base Code:

Once GTM is in your live environment you can compare the data from your new GTM GA property and the GA base code property. Check that all your pageviews are recording and that the data is within a few percentage points of what GA base code is recording. You can also review your custom dimensions as you should now have sufficient traffic to do some custom reporting. I also use the ‘Realtime’ console in GA to compare data as it’s easy to spot any obvious differences between the two GA properties when looking at users currently on the site.

If you are happy that GTM is accurately collecting user behaviour data you can look to remove the GA base code. You can then redirect your GTM data to the old GA base code property so that you don’t lose any historical data. Simply go to the ‘GA Tracking ID’ variable and change the property IDs as necessary.

10. Create GTM Development Plan

Now that you are up and running you can start to create a GTM development plan. This should be based upon your vision for analytics and will probably include strategies for data enrichment and improving data quality. This might include adding tags for;

Summary:

Migrating to GTM for Google Analytics will make a huge improvement to your ability to enhance data quality and data enrichment. It is not the end of a process, it’s the beginning of an ever changing journey to identify new and exciting insights. GTM allows you to work in an agile environment and begin to track every user interaction and event on a website.

Use migrating to GTM as an opportunity to review your vision for web analytics. Begin by creating a development and test plan for GTM which will ensure you approach GTM integrations in a systematic and planned way.

GTM migration also allows you to begin conversations with important stakeholders. You can now offer to assist them in a much more agile and dynamic fashion because you have direct control of the majority of tagging on the site. This is a huge improvement on having GA hard coded on the site. Use it to your advantage.

More reading

How To Create Virtual Page Views in Google Tag Manager

How To Track Users in an Embedded Application with Google Tag Manager

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *