Analytics and Tracking

Variable

A named placeholder in a tag manager that holds a value, such as a page URL or order total, worked out at the moment a tag or trigger needs it.

Quick facts: Variable

Category
Analytics and Tracking
Level
Beginner
Affects
Tag firing, conversion values, event parameters, trigger accuracy
Where to see it
Google Tag Manager (Variables and preview mode), Tag Assistant, GA4 DebugView
In this article4
  1. How variables work
  2. Why it matters
  3. Common mistakes
  4. How to act on it

In tag management, a variable is a named placeholder for a value, such as the page address, the text of a clicked button or the total of an order, which the tag manager works out at the moment it is needed. Instead of typing a fixed value into each tag, you refer to the variable and the current value is filled in.

How variables work

A tag management system such as Google Tag Manager is built from three parts. Tags send data somewhere, triggers decide when, and variables supply the details. Variables are used in two places:

  • In trigger conditions. A trigger might fire only when the variable Page Path contains /thank-you/, or when Click Text equals “Book a call”.
  • In tag fields. A purchase tag might send the variable holding the order value as the conversion value, and the variable holding the order reference as the transaction ID.

Each time something happens on the page, such as a load, a click or a form submission, the tag manager works out the variables afresh for that event. That means the same variable can return different values at different moments. A variable reading the basket total returns nothing on the home page and £86.40 at checkout.

Variables come in two families. Built-in variables are standard values most sites need, switched on with a tick box. User-defined variables are ones you configure for your own site, most often by reading values from the data layer.

Why it matters

Variables are what turn a basic “someone converted” signal into useful data. Without them, a Google Ads conversion has no value, a GA4 event has no detail and every tag carries hard-coded settings that someone has to remember to update. With them, one change to a variable updates every tag that uses it.

They also decide how accurate your triggers are. A trigger that relies on the wrong variable, or one that reads a value which changes after a site update, can fire on every page or on none. A common tracking failure on small business sites is a single variable that quietly stopped returning what everyone assumed it did.

In the UK, variables carry a privacy responsibility too. A variable can read anything on the page, including what a visitor typed into a form. Passing that into an advertising tag without consent, or without telling people in your privacy notice, creates a PECR and UK GDPR problem.

Common mistakes

  • Hard-coding IDs and values in dozens of tags instead of storing them once in a variable.
  • Building triggers on variables that depend on page wording or layout, which break when the site changes.
  • Assuming a variable holds a value on every event when it only exists on one.
  • Leaving unused variables in the container, which makes audits slower and mistakes more likely.
  • Reading form fields into variables and sending them to third parties.

How to act on it

Open your tag manager and list the variables your conversion tags depend on. For each one, ask where its value comes from and what would break it. Anything critical, such as revenue, order ID or lead type, should come from the data layer rather than from page text.

Use preview mode to watch variables change as you click through a real journey, from landing page to thank-you page. Then tidy the container: consistent names, no duplicates, nothing unused, and a note against any variable that depends on page wording so it is checked after every redesign.

If your conversion data looks thin or inconsistent across platforms, a tracking review is usually the right first step, and it is part of how I start any performance marketing engagement.

Do and do not

Do

  • Store IDs and repeated settings once in a variable
  • Source critical values such as revenue from the data layer
  • Check variables on the exact event where each tag fires

Do not

  • Hard-code the same value into dozens of tags
  • Build triggers on page wording that will change
  • Send form field contents to third-party tags

Questions people ask about this

What is a variable in Google Tag Manager?

It is a named value GTM can look up when a tag fires or a trigger is checked, such as the current page URL, the text of a clicked link or an order total from the data layer. You refer to it in double curly braces, and GTM fills in the current value. Variables keep tags flexible and accurate without hard-coded settings.

What is the difference between a variable and a trigger?

A trigger decides when a tag fires, while a variable supplies a value. Triggers often use variables in their conditions, for example firing when the Page Path variable contains a thank-you page. Think of the trigger as the rule and the variable as the information the rule checks.

Do variables slow down my website?

Most variables are light and make no noticeable difference. Custom JavaScript variables that run heavy code, or containers with hundreds of variables evaluated on every event, can add some processing. The bigger performance cost usually comes from the tags themselves rather than the variables.

Related terms

Found this useful?

Share it, or ask an AI to summarise it

Back to the glossary

Knowing the term is the easy part

Applying it to your own site and budget is the work. Book a call and I will tell you what actually applies to you.