Home › How-tos › The Secret Setups › Google Analytics 4
How to set up the GA4 ecommerce dataLayer
Live guide · Checked 28 October 2026 · Updated 28 October 2026 · Checked every week against Google Analytics 4's own help pages
Push view_item, add_to_cart, begin_checkout and purchase in the format GA4 expects, and send them with one tag, so revenue, products and checkout drop-off all show in GA4.
- Time
- 45 minutes
- You will need
- Google Tag Manager and the Google tag for GA4
- A developer or a platform plugin that can add code to product, basket, checkout and order pages
- Stuck?
- Troubleshooting or ask us a question
Step by step
Use GA4's item format
Every ecommerce event carries an
itemslist in the same shape. Use the sameitem_idyour shop uses:{ item_id: 'SKU-1042', item_name: 'Oak desk', item_brand: 'Northwood', item_category: 'Desks', price: 249.00, quantity: 1 }Clear the old ecommerce data first
Before every ecommerce push, clear the last one, or items from one event leak into the next:
window.dataLayer = window.dataLayer || []; window.dataLayer.push({ ecommerce: null });Product page: view_item
window.dataLayer.push({ ecommerce: null }); window.dataLayer.push({ event: 'view_item', ecommerce: { currency: 'GBP', value: 249.00, items: [{ item_id: 'SKU-1042', item_name: 'Oak desk', price: 249.00, quantity: 1 }] } });Basket and checkout: add_to_cart and begin_checkout
Push
add_to_cartwhen something is added (with the items added), andbegin_checkoutwhen checkout opens (with everything in the basket):window.dataLayer.push({ ecommerce: null }); window.dataLayer.push({ event: 'begin_checkout', ecommerce: { currency: 'GBP', value: 298.00, items: [ { item_id: 'SKU-1042', item_name: 'Oak desk', price: 249.00, quantity: 1 }, { item_id: 'SKU-2210', item_name: 'Desk lamp', price: 49.00, quantity: 1 } ] } });Order confirmation: purchase
On the order confirmation page, once per order. The transaction_id stops repeats being counted twice:
window.dataLayer.push({ ecommerce: null }); window.dataLayer.push({ event: 'purchase', ecommerce: { transaction_id: 'ORDER-50231', value: 298.00, // after discounts, before shipping and tax is fine, just be consistent tax: 49.67, shipping: 0, currency: 'GBP', coupon: 'SPRING10', items: [{ item_id: 'SKU-1042', item_name: 'Oak desk', price: 249.00, quantity: 1 }, { item_id: 'SKU-2210', item_name: 'Desk lamp', price: 49.00, quantity: 1 }] } });One trigger for every ecommerce event
In Tag Manager: Triggers > New > Custom Event, tick Use regex matching, and set the event name to:
^(view_item|view_item_list|select_item|add_to_cart|remove_from_cart|view_cart|begin_checkout|add_shipping_info|add_payment_info|purchase|refund)$One GA4 tag for all of them
Tags > New > GA4 Event. Set Event Name to
{{Event}}, open More Settings > Ecommerce and tick Send Ecommerce data with Data source Data Layer. Fire it on the trigger above.Test and publish
In Preview, go from a product to a test order. Check each event in Tag Assistant, then in GA4 DebugView. Publish, and give Reports > Monetisation a day to fill.
Tips from people who set these up every week
- Using Shopify? The Shopify Customer Events Secret Setup does this for you.
- Keep value consistent: always before or always after tax and shipping, or your ROAS will swing.
Troubleshooting: questions and answers
Revenue in GA4 is higher than my shop.
Usually purchase fires again when people reload the confirmation page. Make sure transaction_id is the real order number: GA4 removes repeats with the same id.
Items are missing in reports.
Check every item has item_id or item_name, and that Send Ecommerce data is ticked on the tag.
Official help pages
Let Claude fix the rest of your funnel
Lead Focus is 12 Claude Skills that find the stage of your funnel that's costing you leads, then fix it: ads, landing pages, follow-ups and tracking. One payment, 12 months of updates, and a 14-day refund.
Get Lead Focus · $29.99Still stuck, or have a question?
Tell us where you got to and what you see. We read every message and reply by email, usually the same working day.