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:
- Login to Google Tag Manager account
- Access the container, select the workspace, and navigate to the “Variables” tab
- Scroll to bottom section saying “User-Defined Variable” and hit on New button
- Enter a recognizable name, say “GA – Tracking ID”
- Hit on Choose variable type… to Google Analytics Settings
- Enter the Property Tracking ID [how to find?]
- Make any advanced settings (if required but optional) and hit on Save button
- 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.
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!