Lesson 2 of 6
Constant Variables
① Connect your GTM container
Paste your container ID to load it into this page. It only ever runs here.
Advanced: use a specific environment
A Constant is the simplest variable there is: it holds one fixed value you type once. The point isn't the value, it's avoiding repetition. Paste your GA4 Measurement ID into ten tags and you have ten places to update when it changes; store it in a Constant and you have one.
This is the "don't repeat yourself" habit applied to GTM. IDs, API keys, domains and feature flags all belong in a Constant so the rest of your container references {{GA4 Measurement ID}} instead of a literal string.
Goal
Create a Constant for the Measurement ID, then reference it as {{GA4 Measurement ID}} instead of pasting the value.
Build it in GTM
Create the Constant
Go to Variables → New, click the variable-type box and choose Constant (under "Utilities").Paste the value
In the Value field, pasteG-HT4PLAY01exactly, no quotes, no spaces.Name it clearly
Name itGA4 Measurement IDat the top, then Save. The name is what you'll see in pickers, so make it obvious.Reference it instead of pasting
In any GA4 tag's Measurement ID field, type{{and pickGA4 Measurement ID. Now changing the ID once updates every tag that uses it.
Debug in Tag Assistant
Copy this lesson's live URL and paste it into GTM Preview, that is the page Tag Assistant connects to. It has the clickable elements, so this page stays clean for reading.
- In your GTM, click Preview.
- Paste the live URL above and click Connect.
- Interact with the live page and watch your tag fire in Tag Assistant.
What you should expect to see
{{GA4 Measurement ID}} resolves to G-HT4PLAY01. Any tag referencing it shows the same value, so one edit propagates everywhere.Verify your container
Built it? Export your container, Admin → Export Container, choose your workspace, then drop the JSON here to check it against this lesson.
Drop your container .json here
or browse · checked in your browser, nothing is uploaded