A user-defined variable is a variable you create yourself in Google Tag Manager to pick up a specific value, such as an order total, a form name or a cookie, so your tags and triggers can use it. It sits alongside the built-in variables Google provides, which cover common values like Page URL and Click Text.
How user-defined variables work
In the Variables section of a GTM container, you click New under “User-Defined Variables”, choose a type and tell it where to find the value. Wherever you then write the variable’s name in double curly braces, for example {{DLV – order value}}, GTM swaps in the current value at the moment a tag fires or a trigger is checked.
The types used most often are:
- Data Layer Variable: reads a value your website pushes into the data layer, such as transaction ID or basket value. This is the most reliable source because the developer controls it.
- Constant: stores a fixed value such as a GA4 measurement ID, so you change it once rather than in every tag.
- Lookup Table and RegEx Table: translate one value into another, for example mapping each thank-you page path to a form name.
- 1st Party Cookie: reads a cookie on your own domain.
- DOM Element: reads text or an attribute from the page itself.
- Custom JavaScript: runs a short function and returns its result, for cases nothing else covers.
Why it matters
Most of the valuable data in analytics and ad platforms comes through user-defined variables. A Google Ads purchase conversion without a value, or a GA4 purchase without a transaction ID, usually means a variable is missing or returning nothing. When that happens, bidding is based on conversion counts rather than revenue, and duplicate orders slip through unnoticed.
The source matters too. Values scraped from page text break the day someone redesigns the checkout or changes “Total” to “Order total”. For a small UK shop on Shopify or WooCommerce, a redesign can silently stop revenue tracking for weeks before anyone spots that Google Ads is reporting zero sales value.
Common mistakes
- Relying on DOM Element variables for revenue or IDs when the data layer could provide them.
- Vague names such as “value” or “variable 3”, which make a container impossible to audit a year later.
- Getting the data layer key wrong by a single character or capital letter, so the variable returns “undefined”.
- Sending prices as text with a pound sign, for example “£49.99”, when platforms expect a plain number.
- Custom JavaScript that reads personal details, such as an email field, and passes them into tags without consent or a lawful basis.
How to act on it
Agree a naming convention and stick to it. Prefixing by type, such as DLV for data layer variables, CJS for custom JavaScript and LUT for lookup tables, makes containers far easier to read. Ask your developer to put important values into the data layer rather than leaving you to scrape the page.
Test every new variable in preview mode, checking the Variables tab on the exact event where your tag fires, not on page load. Then delete variables no tag uses any more.
When conversion values look wrong, the cause is often one of these variables, and checking them is a standard part of how I set up tracking for Google Ads management.
