TRACKING SPECIALIST — BARIS ASA · LONDON
Synctag
Start the check → TRACKING SPECIALIST — BARIS ASA · LONDON

READING ROOM › SYMPTOM FILES › SYM-097

SYMPTOM FILE SYM-097 FILED 18 NOV 2026 · REVISED 18 NOV 2026

GTM Data Layer Variable shows undefined, or a Custom Event trigger never fires: the causes that aren't timing.

ALSO FILED AS
  • “GTM Data Layer Variable undefined”
  • “GTM data layer variable returns undefined in Preview”
  • “Google Tag Manager custom event trigger not firing”
  • “GTM Data Layer Version 1 vs 2”
  • “GTM nested dataLayer variable undefined”
  • “GTM variable undefined but dataLayer has the value”
  • “GTM dataLayer.push not showing in Preview”

Baris Asa, tracking consultant, London · Last checked: November 2026

GTM can’t find the key the site pushed, so the variable reads undefined. It’s usually a one-character mismatch. Open GTM Preview, click the message your tag fired on, and compare the Variables tab with the Data Layer tab.

You’ll see this when a tag sends a blank value (GA4 shows (not set), or revenue is 0 or missing) while the developer says the data is there. Most causes below fail the same way: nothing. No error, no warning, just undefined.

  • Wrong name or path: spelling, case, or a missing parent object.
  • Wrong Data Layer Version: a dotted name read as one key instead of nesting, or the reverse.
  • Wrong page or wrong dataLayer: the value was pushed elsewhere.
  • Silent Custom Event trigger: the push has no event key, or the names differ.

This page is for the case where the data is in the push and the variable still reads nothing, on every load. If it fails only on some loads, or only because the tag fired first, that is a timing fault, on file as F-103 and covered in GTM tag fires before the dataLayer is ready. If you can’t open Preview, send the steps in the next section to your developer. If nobody can, that is the work I do as a Google Tag Manager consultant.

How do I see which side is wrong?

You need GTM Preview: in GTM, click Preview and enter your site’s URL (Preview won’t connect?). Load the page, then click the message in the left-hand list that your tag fired on, not Summary.

  1. Open Variables on that message and find your Data Layer Variable. Note its value.
  2. Open the Data Layer tab on the same message, and on the ones before it. Find the key you expect.
  3. Compare the two, character by character.

Read it like this:

  • The key is in the Data Layer tab and the variable reads undefined. The name or the Version is wrong. Sections 1 and 2.
  • The key isn’t in any Data Layer tab on this page. The site never sent it here, or sent it somewhere else. Sections 3 and 4. If the site never sends it at all, that is F-301 , fixed in the site code.
  • The push appears as “Message” instead of an event name. Preview typically labels a push with no event key that way. Section 5.

1. Does the variable name match the key exactly?

Tag Manager returns undefined for a key it can’t find (Simo Ahava’s write-up of the data model covers this), and that is why there is nothing to find in an error log.

  • Spelling or case. transactionId is not transaction_id, and orderValue is not ordervalue. Copy the key from the Data Layer tab into the variable rather than retyping it.
  • A missing parent. The site pushes { ecommerce: { value: 49 } }. A variable named value finds nothing, because value sits inside ecommerce. The name has to carry the whole path: ecommerce.value.
  • Two names for one idea. Google’s guide says to keep names consistent across pages. visitorType on one template and visitor_type on another gives a variable that works on one page and reads nothing on the next.

2. GTM Data Layer Version 1 vs 2: what changes for a dotted name?

A Data Layer Variable has a Data Layer Version setting on its configuration. Google’s help page says Version 1 keeps a dot as part of the key name, and Version 2 interprets dots as nested values. The same name behaves differently:

Variable nameVersionHow it is readResult on { ecommerce: { value: 49 } }
ecommerce.value1one key named ecommerce.valueundefined
ecommerce.value2open ecommerce, read value49
GTM Preview · Data Layer tab beside the variable · worked example, illustrative, not a client account

Version 2 is what you want for the usual ecommerce push. If the site really pushes one key with a dot in its name, the reverse applies: Version 2 tries to nest it and misses. Check the Version on the variable, then check whether the key in the Data Layer tab is one name with a dot in it or an object inside an object. I haven’t relied on a default Version here, because Google’s help page doesn’t state one. Read the setting on the variable.

For items inside an array, a path with an index, such as ecommerce.items.0.item_id, may read the first item, but Google’s help page doesn’t document that form. Test it in Preview before you rely on it.

3. Was the value pushed on this page?

Google’s guide says data layer variables last only while the visitor stays on the current page. A value that matters across pages, such as a logged-in status, has to be pushed on every page.

A variable that resolves on the product page and reads undefined on checkout is often not broken. The checkout template never pushes that key. Look at the Data Layer tab on the page where it fails, not on the page where you built the variable.

4. Did the push go to the dataLayer this container listens to?

Google’s guide covers the first four of these.

  • The array was re-assigned. dataLayer = [{ 'item': 'value' }] overwrites existing values, and Google warns against re-assigning window.dataLayer after the container has loaded. That is the harmful case: it drops what was already pushed. Declare it once with window.dataLayer = window.dataLayer || []; before the snippet, then use push(). (In plain terms: the site’s code replaced the list instead of adding to it.)
  • The name is wrong. The dataLayer object name is case-sensitive. A push to datalayer won’t work.
  • The container uses a custom name. Google lets you rename the data layer in the container snippet. If the snippet says layer and the site pushes to dataLayer, the container never sees it. Compare the two.
  • The push isn’t valid. dataLayer.push takes valid JavaScript objects, and names must be quoted. { new-variable: 1 } is invalid; { 'new-variable': 1 } is not.

A push made inside an iframe goes to that frame’s own window.dataLayer unless the frame’s code targets the parent. That is ordinary window scoping, not a GTM rule, and it is covered in the timing note. The fix: the frame posts the data to the parent page, which pushes it.

5. GTM custom event trigger not firing: the four-step check

A Custom Event trigger fires when GTM detects a push whose event value matches the trigger’s event name, as Google’s trigger help page describes. Check in this order:

  1. Is there an event key? A push that sets values only has no event for a trigger to match, and Preview typically lists it as “Message”. Add event: 'your_event_name' to the same object.
// wrong: values only, nothing can fire on it
window.dataLayer.push({ form_name: 'quote' });
// right: the event key travels with the values
window.dataLayer.push({ event: 'form_submit', form_name: 'quote' });
  1. Do the names match? Google’s page doesn’t say whether the match is case-sensitive, so treat it as exact. View_Item and view_item are separate names until you’ve tested otherwise. Copy the name from the left-hand list in Preview into the trigger.
  2. What does the regex box do? The trigger has a “use regex matching” option. Google warns that .* makes the trigger run on every detected event, including ones Tag Manager and the Google tag emit, and recommends a more restricted pattern. A plain name changes meaning when the box is ticked: in a pattern, form.submit also matches formXsubmit. Leave the box off for a plain name. For several names, use a narrow pattern such as ^(view_item|add_to_cart)$.
  3. Does a trigger filter fail? A trigger set to “Some Custom Events” with a condition, such as Page Path, that doesn’t match won’t fire. Click the tag under Tags Not Fired in Preview and the failing condition is marked.

Which trigger a GA4 tag belongs on is in Which GTM trigger for GA4 tags.

How do I know it’s fixed?

  • In Preview, the Data Layer Variable shows a real value on the message the tag fires on, on every page type where you use it.
  • The tag sits under Tags Fired, not Tags Not Fired.
  • GA4 DebugView or the collect request in the Network panel shows the value at once. Reports follow on GA4’s usual delay, so judge the number in reports after that, not the same hour. The ecommerce push shape and the tags for each step are in GA4 ecommerce tracking with GTM.

A variable that now resolves has only proved the match. If the number in GA4 or the ad platform is still wrong, the fault has moved to the next link in the chain. Case closed when the tag shows under Tags Fired with a value.

Common questions

Why is my GTM Data Layer Variable undefined when the value is in the dataLayer?

The variable and the push disagree about the key. Common causes: a different spelling or case, a dotted path under the wrong Data Layer Version, a value pushed on an earlier page, or a push that sits under a parent object the variable name leaves out. Tag Manager returns undefined for a key it can’t find (Simo Ahava’s data model write-up covers this), so there is no error to see.

What is the difference between Data Layer Version 1 and 2 in GTM?

It sets how a dot in the variable name is read. Google’s help page says Version 1 keeps dots as part of the key name and Version 2 interprets dots as nested values. A name like ecommerce.value therefore only walks into the ecommerce object under Version 2. The setting sits on the variable’s configuration, under Data Layer Version.

Why does my Custom Event trigger never fire when the push is in the dataLayer?

Check four things in order: the push has an event key, its value matches the trigger’s event name, the regex box isn’t changing what the name matches, and no trigger filter fails. In Preview, the message the push created is typically listed as Message when no event key was sent.

Who should I hire to fix a GTM variable that reads undefined?

Whoever can read Preview and the site’s push side by side. The fix is usually one character in the variable or one key in the push. If your agency says tracking is broken and can’t show you the mismatch, that is a diagnosis I do in one session as a Google Tag Manager consultant.

Sources

Read on 18 November 2026:

  • Google for Developers, the data layer (variables last only on the current page and must be pushed on every page; never overwrite or re-assign window.dataLayer; dataLayer is case-sensitive; variable names must be quoted; names should be consistent across pages; push takes valid objects; the data layer can be renamed in the container snippet)
  • Google Tag Manager Help, variables (Data Layer Version 1 keeps dots in the key name, Version 2 interprets dots as nested values)
  • Google Tag Manager Help, custom event triggers (event name entry; “use regex matching”; .* runs on all detected events and a more restricted regex is recommended)
  • Simo Ahava, Google Tag Manager’s data model (a key that isn’t found returns undefined; pushes are merged recursively)

← back to the reading room