
May 2, 2025
Why Using Constant Variable in Google Analytics 4 Setup is a Good Practice
The current process of managing Google Analytics 4 tags in Google Tag Manager looks like this.
First, you create a Google Tag (just like I explain it here). In that tag, you have to enter your Measurement ID.
Then, you create GA4 event tags for additional interactions you want to track. In those tags, you also must enter the same measurement ID.
What if you plan to have 100 Google Analytics 4 tags in the container? You will have to copy/paste the same measurement ID too many times. That’s inconvenient and time-consuming.
But there’s a better way to approach this.
Create a Constant Variable
In Google Tag Manager, go to Variables > New > Variable Configuration > Constant and paste your measurement ID there.
Save the variable.

Use this variable in your GA tags
Every time you create a new Google Tag (or GA4 event tag) in Google Tag Manager, use this variable (instead of manually pasting the ID).
You can do that by clicking the “insert variable” button next to a field.
Or you can start typing double curly braces {{ and then select the variable from the autocomplete list.
And that’s it! Also, there’s another benefit here. If, for some reason, in the future, you have to change the measurement ID in all tags (maybe the company decides to change the GA4 property), you will need to change the ID just in one place – the constant variable.
Update it, and then this change will be inherited by all tags that are using the variable.
Pro-Tip: Naming Your Constant Variable
While you can name your Constant Variable anything, adopting a clear naming convention will make your GTM container easier to manage as it grows. Consider a prefix that denotes it’s a Constant Variable holding a GA4 ID, for example:
- GA4 – Measurement ID
- Constant – GA4 ID
The reason I mention this is that I’ve seen properties where this variable is just called “GA4”, which is not very clear.
When I work with Google Tag Manager, I always try to think, “if someone takes over this container in the future, will they quickly and easily understand what each tag/trigger/variable means?”.
Always try to think about others, too. Bonus karma points 🙂
It can also be other variables
Let me specify this. If you use lookup or regex tables to insert the GA4 measurement in your tags, that’s also fine. The main idea of this blog post is to say that you should use some variable in your GA4 tags to manage the measurement ID. Don’t paste the ID manually in each tag.
Even though manual pasting works fine and will give you the same result (in terms of data accuracy and tag execution), tag management will be more time-consuming. Work smarter, not harder. Store your ID in a variable and use that variable in GA4 tags.
Â
3 COMMENTS
Very helpful and practical guide. Thank you so much
Hi Julius,
This works amazing for GA4 events and also used to work for Google Ads converisons, however lately it seems the constant variable doesnt work anymore for GA conversions. A message wil pop cannot determine if a Google Tag is in your container.
Do you know a workaround this issue, cuz it is very annoying to constantly ad the Conversion ID and then Conversion label for each conversion (honestly im just lazy, and I do not want to do that)
if the data is still sent properly, ignore the warning