How-to
How to Set Up GA4 Ecommerce Tracking with Google Tag Manager
GA4 ecommerce tracking looks intimidating, but it's really one repeatable pattern applied to a handful of events. Get the ecommerce object shape right once, and view_item, add_to_cart, begin_checkout and purchase all fall into place. This guide walks the full funnel in Google Tag Manager, from the GA4 base tag to a clean purchase with revenue.
How GA4 ecommerce works in GTM
Every ecommerce event follows the same three-step path. Your store pushes a standardized ecommerce object to the dataLayer, GTM reads it, and a GA4 Event tag forwards it to Analytics.
The events that make up the standard funnel, in order, are: view_item_list → select_item → view_item → add_to_cart → view_cart → begin_checkout → add_shipping_info → add_payment_info → purchase. You don't need all of them on day one, view_item, add_to_cart, begin_checkout and purchase give you a usable funnel.
Step 1: Set up the GA4 base (configuration) tag
- Store your Measurement ID (
G-XXXXXXX) once in a Constant variable so you can reuse it. - Add a Google Tag (the GA4 configuration tag) firing on Initialization - All Pages.
- Publish, then confirm pageviews appear in GA4's Realtime report before doing anything else.
Do this first
Step 2: Get the ecommerce object onto the dataLayer
GA4 expects a specific shape. The key detail people miss: clear the previous ecommerce object first with dataLayer.push({ ecommerce: null }) so item data from one event doesn't bleed into the next.
// Fire when a product page loads.
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ ecommerce: null }); // clear the previous object
window.dataLayer.push({
event: "view_item",
ecommerce: {
currency: "USD",
value: 29.0,
items: [
{ item_id: "SKU123", item_name: "Enamel mug", price: 29.0, quantity: 1, item_brand: "Acme", item_category: "Drinkware" }
]
}
});On a platform like Shopify or WooCommerce, plugins or a custom pixel push these for you. On a custom store, a developer adds the pushes. Either way, GTM's job is only to read and forward.
Step 3: Read items and send the GA4 event
- Create a Data Layer Variable named
ecommerce.items(and one forecommerce.value,ecommerce.currency). - Create a Custom Event trigger for each event name (
view_item,add_to_cart, and so on). - Add a GA4 Event tag. Set the Event Name to
{{Event}}(the built-in variable) so one tag can handle every ecommerce event, or make one tag per event if you prefer clarity. - Under More Settings → Ecommerce, tick Send Ecommerce data and set the source to Data Layer. This is what maps the
itemsarray correctly.
The shortcut
ecommerce object. You don't have to hand-map every item field, that's the whole point of using the standard shape.Practice this on a real container
The full funnel, view_item through purchase, is best learned by doing. Load your own container into a sandbox store and fire every event end to end, debugged in Tag Assistant.
Practice the ecommerce funnel →Step 4: The purchase event (get this one right)
Purchase is the event that matters most and the one most worth protecting. Two rules:
- Include a unique
transaction_id. GA4 uses it to deduplicate, so a customer refreshing the thank-you page doesn't create a second sale. - Fire on a server-confirmed step when you can, not just any thank-you page load.
window.dataLayer.push({ ecommerce: null });
window.dataLayer.push({
event: "purchase",
ecommerce: {
transaction_id: "T-10492", // unique → dedup
currency: "USD",
value: 129.0,
tax: 8.0,
shipping: 5.0,
items: [
{ item_id: "SKU123", item_name: "Enamel mug", price: 29.0, quantity: 1 },
{ item_id: "SKU777", item_name: "Cafetiere", price: 100.0, quantity: 1 }
]
}
});Step 5: Verify it actually works
- Open GTM Preview and walk the funnel. Each step should show the matching event and a populated
ecommerceobject in the dataLayer. - In GA4, watch Realtime and the DebugView, your events and item details should appear within seconds.
- Confirm revenue lands on
purchaseand thattransaction_idis present. - Give it 24–48 hours, then check the Monetization reports for items and revenue.
Common mistakes
ecommerce: null before each push (items bleed across events), missing transaction_id (duplicate purchases), and firing purchase on a page that can reload.Now go practice it
Reading sticks when you do it. These hands-on lessons load your own GTM container and let you debug in Tag Assistant.
Frequently asked questions
How do I set up GA4 ecommerce tracking in Google Tag Manager?
First add the GA4 base Google Tag and confirm Realtime pageviews. Then have your store push a standardized 'ecommerce' object to the dataLayer for each event (view_item, add_to_cart, begin_checkout, purchase). In GTM, fire a GA4 Event tag on a Custom Event trigger for each event and enable 'Send Ecommerce data → Data Layer' so the items array maps automatically.
What is the ecommerce object in the dataLayer?
It's the standardized structure GA4 expects: a currency, a value, and an items array where each item has fields like item_id, item_name, price and quantity. Pushing this shape lets GTM's 'Send Ecommerce data' setting map everything without manual field mapping.
Why do I need to push ecommerce: null?
The dataLayer persists objects, so item data from one event can carry into the next. Pushing dataLayer.push({ ecommerce: null }) before each ecommerce event clears the previous object so events don't contaminate each other.
Why is GA4 showing duplicate purchases?
Usually a missing or non-unique transaction_id, combined with firing on a thank-you page that can be reloaded or revisited. Always send a unique transaction_id (GA4 uses it to deduplicate) and fire purchase on a server-confirmed step where possible.
Which GA4 ecommerce events should I implement first?
Start with view_item, add_to_cart, begin_checkout and purchase. They form a usable funnel. Add view_item_list, select_item, view_cart, add_shipping_info and add_payment_info later for a complete picture.
Related posts
How-to
How to Set Up Google Tag Manager on Shopify (Storefront + Checkout)
Shopify GTM is two jobs, not one: the storefront installs normally, but the sandboxed checkout needs a custom pixel. The full storefront + checkout setup, GA4 mapping and testing.
Read →How-to
How to Track Form Submissions in Google Tag Manager (Without Losing Conversions)
Form submissions are leads, and the easiest tracking to get wrong. Three reliable methods, plus the redirect gotcha that silently loses conversions and how to beat it.
Read →How-to
How to Set Up Google Ads Conversion Tracking with GTM
Google Ads only optimizes toward conversions it can see. The reliable GTM setup (Conversion Linker plus the conversion tag, with value and dedup), and the mistakes that quietly cost you.
Read →About the author

Analytics & Tag Management Consultant
Nathan Gage got his start in marketing through Google Tag Manager. Seeing how tracking customer behavior could turn raw clicks into insight you can actually act on is what pulled him into the field. Since then he has worked both full time and as a consultant with 15 marketing agencies, supporting brands that spend anywhere from a thousand dollars a month to over a million. Along the way he built a multi-touch attribution app, and he created The Happy Tagger so anyone can practice GTM, GA4 and server-side tracking on a real container instead of a production site.