• Courses
    • Courses
    • Course bundles
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login
  • Courses
    • Courses
    • Course bundles
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login

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.

Subscribe and Get the Ebook - working with reports in ga4

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.

 

Julius Fedorovicius
In Google Analytics Tips
3 COMMENTS
Mary
  • Oct 23 2023
  • Reply

Very helpful and practical guide. Thank you so much

Pascal
  • Apr 16 2025
  • Reply

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)

    Julius Fedorovicius
    • Apr 16 2025
    • Reply

    if the data is still sent properly, ignore the warning

Leave a comment Cancel reply

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


 

Hi, I'm Julius Fedorovicius and I'm here to help you learn Google Tag Manager and Google Analytics. Join thousands of other digital marketers and digital analysts in this exciting journey. Read more
Analytics Mania
  • Google Tag Manager Courses
  • Google Tag Manager Recipes
  • Google Tag Manager Resources
  • Google Tag Manager Community
  • Login to courses
Follow Analytics Mania
  • Subscribe to newsletter
Recent Posts
  • Setting up cookie consent for Microsoft Clarity (V2)
  • Conversion rate in Google Analytics 4
  • Google Tag Manager Data Layer Explained
Analytics Mania - Google Tag Manager and Google Analytics Blog | Privacy Policy
Manage Cookie Settings