How to Migrate To Google Tag Manager For Google Analytics
A Step-By-Step Guide To Migrating to Google Tag Manager:
Google Tag Manager is a powerful free software platform that 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. Further, you can also 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.
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.
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.
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.
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:
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.
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.
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 contact links, outbound links and download link types triggers.
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.
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.
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 like Insert Header and Footer to paste the code in yourself.
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.
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 being recorded 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;
Click events, such as buttons (e.g. add to basket) and navigation links.
Enhanced ecommerce deployment to track product impressions, clicks, checkout and transactions.
Implementing customer experience analytics (e.g. Hotjar) in GTM.
Cross-domain tracking if you have users going between different domains.
Creating new custom dimensions to improve data analysis.
Implementing virtual page views if you have a single page application or one page website.
Building automated dashboards in Data Studio.
Creating an automated funnel visualisation in Data Studio.
Designing in-page analytics reports in Data Studio.
Integrating GTM in a shared payment gateway.
Implementing an A/B testing platform using GTM.
Configuring element visibility tags to create new custom segments in GA.
Creating custom audiences in GA.
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.
Thanks for reading my post. Please leave comments and feedback below because it helps me improve my blogs.
- About the author: Neal provides web analytics and CRO consultancy services. He has worked in many sectors including financial services, online gaming and e-commerce retail. He has helped brands including Hastings Direct, Manchester Airport Group Online, and Assurant Ltd to improve their digital marketing measurement and performance.
- Neal has had articles published on website optimisation on CXL and Usabilla.com. As an ex-market research and insight manager he also had posts published on the GreenBook Blog research website. If you wish to contact us please send an email to email@example.com. You can follow us on Twitter @conversionupl, see Neal’s LinkedIn profile or connect on Facebook.