Creating Google Analytics constant tracking ID variable in GTM

Frequently using the Google Analytics Tracking ID can be stored in a variable and can be used and changed in multiple tags in a single shot. Create a pre-defined variable with a value stored which can be retrieved when required.

I personally use Google tag manager for deploying tags and trigger on my blog. The GTM provides me with the flexibility to deploy unlimited tags and snippet without actually modifying the <head> tag at every instance.

GTM also provides the ability to store information in variables that can be queried while building GTM tag. One of the best features is creating a permanent Google Analytics tracking ID variable, and call it whenever required in every trigger.

In order to create and define a GA variable in GTM, follow the below simple steps:

  1. Login to Google Tag Manager account
  2. Access the container, select the workspace, and navigate to the “Variables” tab
  3. Scroll to bottom section saying “User-Defined Variable” and hit on New button
  4. Enter a recognizable name, say “GA – Tracking ID”
  5. Hit on Choose variable type… to Google Analytics Settings
  6. Enter the Property Tracking ID [how to find?]
    GTM Variable Setting for GA Tracking ID
  7. Make any advanced settings (if required but optional) and hit on Save button
  8. That’s all! Your GTM variable with GA Tracking ID is ready for use

How to use this tracking ID?

Whenever you create a new GTM tag with Universal Analytics tag type, you’ll get an option saying “Google Analytics Settings”, from dropdown just select the Analytics tracking variable that we created in the last step.

Google Analytics Settings GTM Tag

How flexible is using this variable?

Suppose your website is migrating to a different GA Tracking ID, but you want to keep all the tags and triggers intact. You just need to modify the variable tracking ID that we set up in step #6.

All the tags and triggers will automatically consider this new adjusted Property ID without manually modifying every tag — time saver and flexible, isn’t it? I personally use this pre-defined custom variable for an obvious reason.

I hope you’ll also consider using the constant variable. Let me know your thoughts and ideas on it. Cheers!

If you've any thoughts on Creating Google Analytics constant tracking ID variable in GTM, then feel free to drop in below comment box.
Also, please subscribe to our restoreBin YouTube channel for more important updates. Cheers!

Hey there, I hope you doing awesome! I’m Kushal Azza, a certified digital analytics professional, technophile, a blogger & your host at @restoreBin

Leave a Reply

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