dataLayer timing & race conditions
When a GTM tag fires before the dataLayer is ready, it sends its hit before the site has pushed the data the tag reads. In GA4 that shows as real orders with no value, no items or no transaction ID, so revenue runs below the shop's. The fix: push the data with an event key and fire the tag on a Custom Event trigger of that name.
Symptom and cause
- Symptom
- Order values there on some page loads and missing on others: GA4 purchases or product views with no items or a zero value, though the order is real. The same tag passes in testing and fails for real users.
- Cause
- Tags fire before the dataLayer is populated. The tag races the push, or fires on page view while the ecommerce object arrives a beat later.
- Where it's caught
- GA4 Explore: real orders at zero revenue, a (not set) Transaction ID row, fewer purchases than the shop's orders. GTM Preview: the tag's variables undefined on the message it fired on.
How the tag outruns the data
The dataLayer is the list a site fills with product and order details for Google Tag Manager (GTM) to read. A push is one write to it. A tag reads whatever is in that list at the moment its trigger fires. If the push has not happened yet, the variable comes back undefined and the hit goes out without it.
Google's data layer guide says GTM handles messages first in, first out, one at a time, and fires every tag whose trigger is met before it moves to the next message. A push from page code is queued behind the pending messages, and its values are not guaranteed to be available for the next event. Page View, DOM Ready and Window Loaded are messages of their own. They do not wait for the site. A tag on one of them misses order details that a template, cart call or app pushes later. If the transaction ID travels in the same push, it goes missing with the value.
It flickers because the order can change from load to load. A fast cached load fires the tag first; a slower one lets the push win. That is how it passes QA and fails in production. A push that always lands later, such as one placed below the GTM snippet with the tag on Page View, fails every time. Filed as F-103 either way. The fix is the same.
GTM fires tags on events. Give the push an event name (the event key) and a Custom Event trigger of that name fires on the very message that carries the data. Tag sequencing and firing priority do not help: they set the order of tags against each other, and nothing in them waits for the site's push.
It is not only GA4. Any tag in the container that reads the same variables on the same trigger, such as a Google Ads conversion tag sending the order value, goes out empty on the same loads.
The change itself is one push and one trigger per affected event, once the site can push the data at the right moment. Most of the work is proving it across loads.
Two related shapes. In a single-page app, History Change (GTM's trigger for a URL change without a page load) can fire before the new page has pushed its data. And GTM merges pushes rather than resetting them, so an earlier product's items can carry into a later event: wrong values rather than missing ones.
| ms from start | Preview message | order details | GA4 purchase tag |
|---|---|---|---|
| 0 | Initialization | not pushed yet | not on this trigger |
| +14 | Container Loaded (Page View) | still not pushed | fires · value: undefined · items: undefined |
| +90 | purchase (the site's push) | value + items present | already sent, does not fire again |
| +92 | DOM Ready | value + items present | only a tag on this message reads them, this time |
How to catch it
- Start in GA4, no GTM access needed. In Explore, open a free-form table for a closed week with Transaction ID as the dimension and Ecommerce purchases, Purchase revenue and Items purchased as the metrics.
- Look for three signs: real orders at zero revenue or zero items, a (not set) Transaction ID row, and fewer GA4 purchases than the shop's orders. Rule out free orders. The gap against the shop's order list for the same week is the most this fault can be costing you, not the exact cost: consent and ad blockers sit in the same gap. These signs say something is wrong, not which fault. Preview tells you which.
- From here it is GTM work. Open Preview, place a test order and click the message the tag fired on in the left-hand list, not Summary. Summary shows the values after every push has merged, which hides the race. In Variables, items or value reading undefined on that message is the first sign.
- Open the Data Layer tab on the later messages and find the push carrying items and value. If it comes after the message the tag fired on, the tag outran the data. Timing changes from load to load, so repeat on several loads, one with the cache disabled. Late on some loads is a race. Late on every load is a fixed late push. Both are F-103.
- Rule out the lookalikes. Values that never appear in the Data Layer tab at all are F-301: the site never sends them. A parameter present on every hit but missing from reports is F-601: never registered. A tag that fires in Preview but never for real visitors is a publishing, container, consent or URL problem, not a race. A value sent without currency can also leave revenue wrong: Google says that if you set value, currency is required for revenue metrics to be computed accurately.
- Optional, for the developer: read the hit itself in DevTools, Network, with Preserve log on and a filter for collect, or in GA4 DebugView with debug enabled through Tag Assistant.
What putting it right involves
- If you do not run GTM yourself, this is one message to your developer: the push below, plus a Preview screenshot of the tag firing before it.
- Developer: push the values and the event key in one object, once the data exists. On the order confirmation page, for example: dataLayer.push({ ecommerce: null }); then dataLayer.push({ event: 'purchase', ecommerce: { transaction_id: 'T1001', currency: 'GBP', value: 49.00, items: [ ... ] } }).
- GTM: move the GA4 event tag onto a Custom Event trigger whose event name matches that key character for character. Purchase and purchase are different names. The tag now fires on the push itself. Move any other tag that reads the same values, such as a Google Ads conversion tag, onto the same trigger.
- Values known when the page renders, such as page type or login status, go in a push above the GTM snippet, after window.dataLayer = window.dataLayer || [], as Google's data layer guide advises. Never re-assign window.dataLayer later in the page: Google warns it wipes what is already there. Values a cart, app or API sets later cannot be moved up. They need the two steps above.
- Do not cure it with a later page-load trigger, a timer, tag sequencing or firing priority. DOM Ready and Window Loaded only help if the push reliably finishes first, and a late push does not. Sequencing and priority only set the order of tags.
- Single-page apps: have the developer push a named event, with its values, once the new page's data is ready, and trigger on that instead of History Change.
- If the values are wrong rather than missing, push ecommerce: null before each ecommerce push, as every sample in Google's ecommerce guide does, so one product's items do not carry into the next event.
- Case closed when every tag fires on its own push, every variable resolved, on several loads in Preview, one with the cache disabled. Then a closed week in GA4: zero-value orders and the (not set) Transaction ID row should fall to near nothing. Any gap left against shop orders is consent, blockers or F-301, not this fault. Moving the trigger recovers data the site pushes. It cannot invent fields that were never sent.
Sources on file
- Google for Developers: The data layer (Tag Manager processes messages on a first-in, first-out basis, and tags whose trigger conditions are met fire before it moves on to the next message; a push from page code, Custom Templates or Custom HTML tags is queued and processed after all other pending messages, and updated values are not guaranteed to be available for the next event; add an event name and listen for it with a Custom Event trigger; establish the data layer before Tag Manager loads, as high in the source as possible; never overwrite or re-assign window.dataLayer; checked 24 Nov 2026)developers.google.com
- Tag Manager Help: Page view triggers (Consent Initialization, Initialization, Page View, DOM Ready, Window Loaded and when each fires; DOM Ready for page-view tags that read values from the DOM; checked 7 Nov 2026)support.google.com
- Google for Developers: Measure ecommerce, Tag Manager version (every code sample pushes ecommerce: null before the event, commented 'Clear the previous ecommerce object'; checked 7 Nov 2026)developers.google.com
- Google for Developers: GA4 recommended events reference, Tag Manager version (if you set value then currency is required for revenue metrics to be computed accurately; checked 7 Nov 2026)developers.google.com
- Tag Manager Help: Tag sequencing (a setup tag fires before the primary tag, a cleanup tag immediately after it; checked 7 Nov 2026)support.google.com
- Tag Manager Help: Tag firing priority (determines the order in which tags fire; tags will still fire asynchronously; checked 7 Nov 2026)support.google.com
- Google Analytics Help: Monitor events in DebugView (Admin, then Data display, then DebugView; enable debug through Tag Assistant or preview mode; checked 7 Nov 2026)support.google.com
- Simo Ahava: Add the 'event' key to dataLayer pushes (a data-only push gives GTM nothing to fire on and can be overwritten before a tag reads it)www.simoahava.com
- Simo Ahava: Google Tag Manager's data model (pushes are merged, not reset, so a value persists until it is overwritten or the page reloads)www.simoahava.com
Cited in these case files
F-103 turns up as evidence across the archive. It is cited in:
- SYMPTOM TikTok Pixel and Events API purchases don't match Shopify: event_id deduplication and what Events Manager shows If TikTok reports more purchases than your Shopify store took, the Pixel and the Events API may both be reporting each order without the same event name and event_id. A first check against store orders, why deduplication stops working on Shopify, how to prove it with one test order in TikTok Events Manager, and which gaps are attribution, not duplicates.
- SYMPTOM GTM tag works in Preview but not on the live site: how to find which of five causes it is The lookalike. A tag that fires in Preview and never for visitors is a publishing, container, cache, consent or URL problem, not a race. Five causes in the order to check them.
- SYMPTOM GA4 not tracking page views on a single-page app: history change triggers in GTM On a single-page app GA4 counts the landing page and then nothing, or counts every screen twice. Which of five cases you have, read in DebugView in five minutes, and the fix for each, with Google's History Change trigger setup for GTM sites.
- SYMPTOM GTM Data Layer Variable shows undefined, or a Custom Event trigger never fires: the causes that aren't timing GTM can't find the key the site pushed, so the Data Layer Variable reads undefined. It's usually a one-character mismatch: spelling, case, a dotted name under the wrong Data Layer Version, a value pushed on another page, or a push sent to a different dataLayer. A silent Custom Event trigger means no event key or a different name.
- SYMPTOM Tag Assistant says Google tag not found, or shows the wrong tag ID Tag Assistant reports no Google tag, or a GT- ID where you expected your G- Measurement ID. Not found usually means the page you tested didn't load the tag. A GT- ID is often your own tag under its other ID. Compare the ID the page loads with Tag details in your Google tag settings, then fix whichever side differs.
- SYMPTOM Which GTM trigger for GA4 tags: Initialization, Page View, DOM Ready or Window Loaded The trigger side of the fix. Which trigger each GA4 tag belongs on, why event tags that need the site's data go on a Custom Event, and how to read the trigger in Preview.
- FIELD NOTE Auditing dirty ecommerce marketing data: the signs, and what gets cleaned first How to choose who audits dirty ecommerce data, the signs you can see in your own reports, the fault each one points to, the order an audit cleans them in, and which months you can trust afterwards.
- FIELD NOTE GTM container audit: what gets checked and what you get back A Google Tag Manager audit reads one container without changing it: tags, triggers, variables, the dataLayer, custom scripts, consent, access and versions. You get back an inventory with a keep, fix, remove or add call on each item, a findings register with evidence and severity, an access list and a list of what wasn't checked.
- FIELD NOTE Cleaning up a messy GTM container: the order to work in without breaking tracking Clean a Google Tag Manager container in six steps: back up, list and measure, pause dead tags, fix triggers, replace custom code, rename last. One named version per step, checked against your orders after each publish, so any change that moves a number can be found and rolled back.
- SYMPTOM GTM Preview won't connect: why Tag Assistant says not connected or shows no tags GTM Preview fails when Tag Assistant can't find your container on the page it opened. The usual causes: the snippet isn't on that page, something blocks it, a redirect drops the debug parameter, or the tag sits where Tag Assistant can't follow. Connected with no tags is a trigger problem. Start with gtm.js in the Network tab.
- SYMPTOM GA4 custom parameters not showing in reports: what to check, in order A custom parameter that shows in GA4 DebugView but not in reports is usually unregistered: GA4 only reports custom parameters set up as a custom dimension or metric. The other causes are a near-miss name, a dimension under 48 hours old, the wrong scope, or test traffic a filter removes. A check in order, starting with one you can do without a developer.
- SYMPTOM WooCommerce orders not showing in GA4: plugin conflicts, payment redirects and the thank-you page WooCommerce has the order and GA4 has no purchase event for it. What the missing orders share narrows it down: one payment method points to the gateway return, a custom thank-you page to the page itself, one order status to the plugin's status setting, everything from one date to a cache, an update or a second tracking plugin.
- SYMPTOM GTM in a Shopify custom pixel: why events go missing and what the sandbox can't see GTM in a Shopify custom pixel runs walled off from the shop and only receives what the pixel's code hands it. The four reasons events or fields never reach GA4, Google Ads or Meta, a three-minute owner check, how to test without GTM Preview, and when the Google & YouTube or Facebook & Instagram app is the better route.
- SYMPTOM Enhanced Conversions in GTM: which setup method to use and how to verify it How to set up Enhanced Conversions in Google Tag Manager: turn it on, then choose how the container collects the email (automatic, CSS selectors, code from the dataLayer, or the User-Provided Data event tag). Which method fits your site, where each breaks, and the test that proves the hashed email reached Google Ads.
- SYMPTOM How to set up GA4 ecommerce tracking with GTM: the dataLayer it can actually read To set up GA4 ecommerce tracking with Google Tag Manager, the site's code pushes each shop event to the dataLayer inside an ecommerce object, clearing the previous one first, and one GA4 Event tag sends them all. The push for each funnel step, why the clear matters, the tag and trigger, and how to test it.
- SYMPTOM GA4 purchase event not firing at all: where the order gets lost The shop takes orders and GA4 records no purchase for them. The order was lost at one of four points: the shopper never reached the thank-you page, the purchase tag never fired, consent stopped it, or GA4 dropped it. A week of shop orders against GA4, then one test order, shows which.
- SYMPTOM How to check Meta Pixel and CAPI deduplication is working: proving the event_id matches A step-by-step check that Meta merges your Pixel and Conversions API copies of a purchase: read the event_id and event name on both sides, confirm in Events Manager, and know which readings prove nothing.
- SYMPTOM GA4 purchase events missing items or value: which field is broken GA4 purchases with no revenue or no products mean a detail inside the purchase event is wrong: value sent as text or with a £ sign, currency missing or not a three-letter code, items empty or without an ID or name, or a Google Tag Manager tag that never passes the ecommerce data. DebugView shows which.
- SYMPTOM GTM tag fires before the dataLayer is ready: how to prove it and fix the trigger The symptom as it is usually asked. A check in GA4 without GTM access, the Preview read-out, the shapes it takes (Shopify custom pixels included) and the push and trigger to send the developer.
- SYMPTOM Meta CAPI and Pixel double counting purchases: what checks should I run? Six checks, in order, for Meta counting one sale twice after the Conversions API went live: the right number, the same event_id, the same event name, one sender per side, the 48-hour window, and the Event Deduplication tab. Then the six ways it breaks and the test that proves it is fixed.
Questions on this file
Why does my GTM tag fire before the dataLayer is ready?
Because its trigger is tied to the page load, not to the data. Page View, DOM Ready and Window Loaded fire at fixed points, and the site's push lands whenever its own code finishes. Google says a push from page code is queued behind pending messages and its values are not guaranteed for the next event. Push the data with an event key and fire the tag on a Custom Event trigger of that name. The step-by-step version, with a Shopify custom pixel section, is in the note on proving and fixing it.
Does the order of dataLayer.push calls matter?
Yes. Google's data layer guide says GTM processes messages first in, first out, one at a time, and fires every tag whose trigger is met before it moves on. A tag can only read values pushed on its own message or an earlier one. So the push carrying the order details must be the message the tag fires on, which is what an event key and a Custom Event trigger give you.
How do I check whether it is happening on my store?
In GA4 Explore, list Transaction ID against Ecommerce purchases and Purchase revenue for a closed week. Real orders at zero, a (not set) Transaction ID row and fewer purchases than shop orders are the usual signs. Then confirm in GTM Preview: the push carrying items and value appears after the message the tag fired on.
Should the dataLayer go above the GTM snippet?
Yes, for values known when the page renders. Google's guide establishes the data layer before Tag Manager loads, with window.dataLayer = window.dataLayer || [], and says never to overwrite or re-assign window.dataLayer afterwards. Values a cart, app or API pushes later cannot be moved up, so those need a Custom Event trigger.
Which trigger should the GA4 tag use instead?
For an event that needs the site's data, a Custom Event trigger named after the push. Page View suits events that need only the visit, and DOM Ready tags that read the page's HTML. The note on which GTM trigger each GA4 tag needs has the full table and how to check yours in Preview.
Will DOM Ready, Window Loaded, tag sequencing or firing priority fix it?
No, though all four are often suggested. A later page-load trigger only helps if the push always finishes first, which is exactly what you cannot count on. Tag sequencing fires a setup tag before the main tag, or a cleanup tag after it. Firing priority sets which tags fire first, and Google notes they still fire asynchronously. None of them waits for the site's own push.
My tag works in Preview but not on the live site. Is that F-103?
Usually not. F-103 shows in Preview itself: the tag fires, but its variables read undefined on that message. A tag that fires cleanly in Preview and never for real visitors points to an unpublished change, a different container, a cached page, consent or a URL mismatch. The note on tags that work in Preview but not live walks through those five.
How is F-103 different from F-301 and F-601?
Look in the Data Layer tab in GTM Preview. Values that arrive on a later message than the tag's are F-103, fixed by changing the trigger. Values that never arrive are F-301, fixed in the site code. A parameter present on every hit but missing from reports or showing (not set) is F-601: it was never registered as a custom dimension.
Who fixes a GTM tag firing before the dataLayer is ready?
Two hands, often one person. A developer changes the push so the values and the event key travel together. Whoever runs GTM moves the tag onto a Custom Event trigger and tests it. What you should get back: the Preview evidence of the race, the exact push for the developer, the trigger change, and a closed week in GA4 compared with shop orders before and after. That is GTM work I take on.