Generate the dataLayer.push your developers need
Most broken GA4 ecommerce comes from a data layer that doesn't match Google's schema. Pick an event, fill in your fields and copy code that GTM and GA4 will read correctly.
Choose an event
Why the format matters
GA4 only fills its ecommerce reports when the data layer matches Google's schema exactly: an ecommerce object with value, currency and an items array. A price sent as a string, a missing currency or a reused ecommerce object from the previous event is enough to break revenue reporting.
- Push
{ ecommerce: null }before each ecommerce event so values from the last one don't carry over. - Send numbers as numbers:
129.00, not"$129". - Fire
purchaseonce, on the confirmation page or server response, with a uniquetransaction_id.
More patterns and edge cases are in the data layer guide. Purchases missing in GA4? See why the purchase event isn't tracking.
FAQ
Where do I put dataLayer.push?
In your site code at the moment the action happens: after the order is confirmed for purchase, when the item is added for add_to_cart, after a successful form submission for generate_lead. The Google Tag Manager snippet must be on the page.
Why push ecommerce: null first?
GTM merges data layer pushes. Clearing the ecommerce object stops items or values from a previous event leaking into the next one.
Does this work with Shopify?
Shopify's checkout runs in a sandbox, so purchase tracking there uses a custom pixel rather than a direct data layer. Our Shopify guide shows how.
Found a problem you'd rather not fix yourself?
We audit and fix GA4, GTM and consent setups at a fixed price.
More free tools
Tracking health check
Is GA4 counting correctly and is consent working? 12 checks on any page, with what each problem means for you.
Cookies before consent
Is your site setting ad cookies before visitors agree? Get a fix ticket for your developer.
Who receives my visitor data?
Every ad platform your site sends data to, including old accounts you forgot about.
Pages missing from GA4
Find sections of your site that never show up in your reports, or that load a second container.
Is Consent Mode working?
Paste one GA4 hit and see whether Google Ads gets the consent signals it needs.
How far back can I analyse?
See how much history your retention setting is costing you, and the two-minute fix.