Guide 105 · Container · GA4 + Tag Manager
Create a constant variable: one place to change a value every tag shares
Some values are the same on every page load: a Measurement ID, a conversion ID, an account number. Typing that value into every tag means every tag has to be edited when it changes. A constant variable holds the string in one place, and every tag references the variable instead. Google's variable page puts it plainly: the value is set to a string you provide, and constant string variables are commonly used when there are multiple tags that use the same account number. The worked example stores one Measurement ID and puts it in three tags.
After step 4, the three tags in the worked example each show {{Constant - Measurement ID}} where the Measurement ID used to sit, and Preview mode shows all three sending to the same property.
Download the container fragment: the constant variable fragment (JSON) (export format version 2, 2479 bytes, MD5 cc3db9966ebd8820cb104234648d0892). It holds the Constant - Measurement ID variable and three tags that read it — one Google tag and two GA4 event tags. The file is a hand-built import template, validated structurally — it was not exported from a live container.
What you need
- The string to store. For the worked example, the Measurement ID from the GA4 web data stream, starting with
G-. Copy it from Admin, then Data Streams, then the web stream — do not type it from memory. - At least two tags that use the same value. A constant earns its keep when the value is shared. One tag with one value does not need one.
- Edit access to the container. Creating a variable is a container edit.
The trace
- Go to Variables and click New under User-Defined Variables. The Variables page has two sections; user-defined variables are the lower one.
- Click Variable Configuration and choose Constant. Constant is listed under Utilities. Pick it and the configuration shows a single field: the string to store.
- Enter the Measurement ID and name the variable after it. Paste the ID — the placeholder in this guide's fragment is
G-XXXXXXXXXX— and name the variableConstant - Measurement ID. The name has to say what the string is, because the value is hidden inside the configuration. - Replace the hard-coded ID in the three tags. Open each of the three tags that use the Measurement ID — the Google tag and two GA4 event tags in the worked example — and replace the ID with
{{Constant - Measurement ID}}. That is 3 tags now reading 1 variable: a future ID change is 1 edit instead of 3, saving 3 − 1 = 2 edits every time the value changes.
Dead ends
DEAD END — A CONSTANT FOR A VALUE THAT CHANGES PER PAGE. A constant holds one string for every page load. A value that differs per page — a page title, a product price — needs a data layer variable or a URL variable instead. A constant named after a page value returns the same answer on every page.
DEAD END — STORING A SECRET IN A CONSTANT. A constant is visible to anyone with Read access to the container, and it travels inside the exported container file. API keys and passwords do not belong in constants — or in the container at all.
DEAD END — ONE CONSTANT PER TAG. Three tags sharing one ID need one constant, not three constants holding the same string. A constant per tag is the same maintenance burden as hard-coding, with an extra layer in between.
End state
One constant, Constant - Measurement ID, read by three tags. The Measurement ID now has exactly one home in the container, and rotating it is a single edit followed by a publish.
Sources
- Tag Manager Help — User-defined variable types for web — constant variable type, the string you provide, the use case of multiple tags sharing one account number, Variables then New then Variable Configuration
Checked 11 November 2026. The click paths above are the ones in Google's help pages, opened 11 November 2026. No step in this guide was run inside a live Analytics property or a live Tag Manager container, because both need a Google sign-in and this site does not sign in as anyone. The container file was validated structurally instead: export format version 2, every tag's firing trigger resolves, every variable the tags reference exists in the file, and the tag types are the documented ones. Google moves menu items without warning; if a path on this page no longer matches, the linked help page is the current map. The container fragment for this guide is 2479 bytes (2.42 KB, 1.21% of the reported 200 KB container size limit), MD5 cc3db9966ebd8820cb104234648d0892, and passed 26 structural checks.