Don't have one? Create one ↗
← All courses

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

  1. Create the Constant

    Go to Variables → New, click the variable-type box and choose Constant (under "Utilities").
  2. Paste the value

    In the Value field, paste G-HT4PLAY01 exactly, no quotes, no spaces.
  3. Name it clearly

    Name it GA4 Measurement ID at the top, then Save. The name is what you'll see in pickers, so make it obvious.
  4. Reference it instead of pasting

    In any GA4 tag's Measurement ID field, type {{ and pick GA4 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.

  1. In your GTM, click Preview.
  2. Paste the live URL above and click Connect.
  3. Interact with the live page and watch your tag fire in Tag Assistant.

What you should expect to see

In Tag Assistant's Variables tab, {{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

0 of 6 lessons complete