This is a great tip and one that is used frequently! Setting up your Google Analytics Tracking ID as a Google Tag Manager variable is a fast, easy way to roll out updates to any account, as well as test Google Tag Manager integrations on a live site without tampering with data. More on that later – for now, let’s get started.
Create A New Variable -> Constant
First, you’ll want to create a new Constant – that’s because our Tracking ID should be absolute and never subject to any programmatic changes.
Create a new variable, give it a descriptive name, and then add in your Tracking ID as the value.
Use Our Variable In Every GA Tag And Event
When creating any Google Analytics tags or events, for the Tracking ID, use a variable:
Two Awesome Uses For This
- Sites that are live with Google Analytics, but need to migrate to Google Tag Manager. Simply create a dummy Google Analytics account, paste in the dummy Tracking ID as your new GTM variable, and use the variable for each and every GA tag and event. In this instance, a site can already be live with Google Analytics and the dummy GTM & GA account allows you to test your integration in a separate property to ensure everything is tracking. As you prepare to go live, update the GTM variable containing the dummy Google Analytics Tracking ID with the real Tracking ID (and remove the old Google Analytics account code from the site!), and you’ve got an effortless rollout.
- Sites that are in development, and cannot push data to a live Google Analytics profile. This happens a lot as well – an existing site is live and tracking while a new site is in development. The goal is to seamlessly transition to Google Tag Manager when the new site launches. Just as above, create a dummy Google Analytics account, paste in the dummy Tracking ID as your new GTM variable, and test your in-development site for tagging. Just before launch, replace the dummy Tracking ID with the real Tracking ID, and you’ve got another smooth GTM integration.
Got any tips for using Google Tag Manager variables? I’d love to hear about them below in the comments!