On this page
What this issue is
Google Tag Manager (GTM) reads values from the dataLayer, a JavaScript array on your page where the site pushes data such as transaction_id or value. A Data Layer Variable in GTM looks up one key by name. If the site now pushes order_total but the variable still looks for orderValue, GTM finds nothing and the variable returns undefined.
// Old push, the GTM variable reads "orderValue"
dataLayer.push({ event: 'purchase', orderValue: 89.00 });
// After the rename, the variable still reads "orderValue" and gets undefined
dataLayer.push({ event: 'purchase', order_total: 89.00 });Why it costs you leads or sales
Ad platforms learn from the values you send. If conversion value, transaction ID or product data goes missing, reports show conversions with zero revenue, duplicate orders or no match to the right campaign. Smart bidding then optimises on poor data. Because the tag still fires, nobody sees an error.
- Site pushes dataKey renamed to order_total
- GTM variable lookupStill reads orderValue, returns undefined
- Tag sends hitValue field empty
- Ad platform reportingRevenue missing or zero
The site renames the key, so everything after the variable lookup carries an empty value.
Example: the same real sales, but reported value drops to zero once the variable returns undefined.
How to check if your site has it
Open GTM PreviewGoogle Tag Manager
In your container click Preview, enter your site URL and complete the action, such as a test purchase or form submit.
Select the event in the Tag Assistant timelineGoogle Tag Manager
Click the event (for example purchase) in the left column, then open the Variables tab.
Look for undefined valuesGoogle Tag Manager
Any Data Layer Variable showing undefined is a candidate. Compare its name with the Data Layer tab for the same event.
Check the page directlyCustom code
In the browser console type dataLayer and expand the entries to see the keys the site really pushes.
dataLayer.forEach(function (e, i) { console.log(i, Object.keys(e)); });How to fix it
Decide which side is right. Usually it is simpler to update the GTM variable to the new key. If many tools depend on the old name, ask the developer to push the old key as well.
Open the variable
Go to Variables, open the Data Layer Variable that returns undefined.
Update the name
Set Data Layer Variable Name to the new key exactly, for example order_total or ecommerce.value.
Optionally set a default
Tick Set Default Value only for harmless fallbacks. Avoid defaults like 0 for revenue, as they hide breakage.
Test and publish
Check in Preview, then Submit and Publish the workspace.
Check the plugin
If a plugin such as a GTM or WooCommerce data layer plugin pushes the data, check its changelog and settings for renamed keys after an update.
Match GTM to the plugin
Update the GTM variable names to what the plugin now pushes, or roll back the plugin version.
Check theme or app changes
A theme update or app that pushes to the dataLayer may have changed key names. Compare the dataLayer in the console on a product or order page.
Update variables
Point your GTM variables at the new keys.
Restore or alias the key
Push both names during a transition so old and new variables work.
Document the schema
List every key GTM relies on so developers know a rename breaks tracking.
dataLayer.push({
event: 'purchase',
order_total: 89.00,
orderValue: 89.00 // legacy key, remove once GTM is updated
});Broken
- Variable reads orderValue
- Site pushes order_total
- Variable shows undefined in Preview
- Tag sends empty value
Fixed
- Variable reads order_total
- Site pushes order_total
- Preview shows 89
- Tag sends the real value
How to confirm it's fixed
- In GTM Preview the variable shows a real value on the event, not undefined
- The tag's fired details show the value, ID and currency populated
- In GA4 DebugView the event parameters carry the value
- The browser Network tab shows the hit with the value parameter filled
- A real or test conversion appears in the ad platform with the right value after processing time
How to prevent it happening again
- Keep a written dataLayer spec listing keys, types and example values
- Make developers check the spec before renaming keys
- Review GTM Preview after every theme, plugin or checkout change
- Use GTM version notes so changes are traceable
- Avoid default values that hide missing data
- Run a scheduled test of key journeys so a change is caught within a day
How FunnelGuard handles this
FunnelGuard detects this only partly. A robot visitor runs your real journeys on a schedule and checks the tracking hits sent to platforms such as GA4, Google Ads and Meta. Its params rules catch empty values, so if a variable returns undefined and a hit goes out with a blank value or ID parameter, that can be flagged, with a screenshot and a likely cause.
Questions people ask
Why is my GTM variable showing undefined?
The Data Layer Variable is looking for a key that is not in the dataLayer at that moment. Common causes are a renamed key, a typo or different case, a wrong nested path, or the variable being read before the push happens. Compare the variable name with the Data Layer tab in GTM Preview.
How do I fix a Data Layer Variable returning undefined?
Open the variable in GTM and set the Data Layer Variable Name to the exact key the site pushes now. Test in Preview, then publish. If the site should keep the old name, ask your developer to restore it.
Why is my GA4 purchase value empty or zero?
Often the variable feeding the value parameter returns undefined because the dataLayer key changed. Check the purchase event in GTM Preview and see whether the value variable has a real number.
Can a plugin or theme update rename dataLayer keys?
Yes. Plugins and themes that push data to the dataLayer can change key names in an update. After updates, compare the dataLayer in the browser console with what your GTM variables expect.
Should I set a default value for a Data Layer Variable?
Only for harmless cases. A default such as 0 for revenue hides the problem, because reports look populated but are wrong. Leaving it undefined makes breakage visible in Preview.
How do I see what is in my dataLayer?
Type dataLayer in the browser console and expand the entries, or open the Data Layer tab for an event in GTM Preview. Both show the real key names and values.
Can FunnelGuard detect undefined GTM variables?
Partly. Its params rules catch empty values in the tracking hits it checks, but it does not read your container or compare key names. Check Preview by hand after changes.
Related issues
- TRK-114Lookup table variable missing a new page/productFix guide
- TRK-115Custom HTML tag throwing JavaScript errorFix guide
- TRK-108Trigger depends on CSS class that changed after redesignFix guide
- TRK-110Trigger condition uses Page URL that no longer matchesFix guide
- TRK-112Tag sequencing broken (setup tag fails, main tag skipped)Fix guide
- TRK-106Trigger set to All Pages instead of thank-you pageFix guide