TRACKING SPECIALIST — BARIS ASA · LONDON
Synctag
Start the check → TRACKING SPECIALIST — BARIS ASA · LONDON

READING ROOM › SYMPTOM FILES › SYM-038

SYMPTOM FILE SYM-038 FILED 07 NOV 2026 · REVISED 07 NOV 2026

How to set up GA4 ecommerce tracking with GTM: the dataLayer it can actually read.

ALSO FILED AS
  • “How to set up GA4 ecommerce tracking with GTM”
  • “GA4 ecommerce dataLayer example”
  • “GA4 ecommerce events GTM trigger setup”
  • “GTM Send Ecommerce data option GA4”
  • “why push ecommerce null before dataLayer push”
  • “one GA4 event tag for all ecommerce events”
  • “GA4 add_to_cart dataLayer push”
  • “GA4 items array dataLayer format”
  • “GA4 ecommerce funnel events with Google Tag Manager”

Baris Asa, tracking consultant, London · Filed 7 November 2026 · Last checked: 7 November 2026

To set up GA4 ecommerce tracking with Google Tag Manager (GTM), the site’s code pushes each shop event (view_item, add_to_cart, begin_checkout, purchase) to the dataLayer, a list on the page that GTM reads. The fields go inside an ecommerce object, with { ecommerce: null } pushed just before. In GTM, one GA4 Event tag sends them all. Get the push wrong and GA4 shows baskets with products nobody added, or purchases with no revenue.

On Shopify? This setup doesn’t reach your checkout. Shopify’s checkout and thank-you pages don’t run your theme’s code, so the purchase usually comes from an app pixel (such as the Google & YouTube app) or a custom pixel. See Shopify tracking apps: what each one sends. This note is for WooCommerce, Magento and custom builds.

The four parts:

  1. Clear first. Push { ecommerce: null } before every ecommerce event.
  2. Push the event with its fields inside ecommerce.
  3. One GA4 Event tag. Event Name {{Event}}, Send Ecommerce data on, Data Source Data Layer.
  4. One trigger. A Custom Event trigger (it fires when the site pushes a named event) matching ^(view_item|add_to_cart|begin_checkout|purchase)$.

Parts 1 and 2 are developer work in the site’s code, or a plugin’s. Parts 3 and 4 are GTM work. When a setup is broken, look at the push first: F-301 and F-103 , both on file, are push faults.

Not technical? Ask your developer for the pushes in the push sheet below and your GTM person for one tag. Accept the work when the test passes.

Is my GA4 ecommerce tracking working?

No code and no GTM access needed. In GA4, Reports, Engagement, Events, set to a full week that ended at least two days ago (reports can take 24 to 48 hours to fill).

  • All four names are listed: view_item, add_to_cart, begin_checkout, purchase. A missing name is an event that isn’t pushed.
  • The counts usually shrink down that list. Fewer add to basket than view, fewer buy than check out.
  • The purchase count is close to that week’s orders in your shop’s back office. A small gap is normal: some shoppers decline cookies or block trackers. Every order missing, or far fewer, is a fault.
  • Purchases are there but revenue reads £0, or far under the back office. That’s a diagnosis, in GA4 purchase events missing items or value. A tag firing before the data exists is in GTM tag fires before the dataLayer is ready.

Something off? The rest of this note is the build sheet for whoever writes the pushes and whoever runs GTM.

What does a GA4 ecommerce dataLayer push look like?

Every ecommerce event takes the same shape. Here is add_to_cart, pushed when the basket confirms the add:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ ecommerce: null }); // clear the last ecommerce object
window.dataLayer.push({
  event: 'add_to_cart',
  ecommerce: {
    currency: 'GBP',
    value: 64.00,              // price x quantity of what was added
    items: [
      {
        item_id: 'MUG-STONE-01',
        item_name: 'Stoneware mug',
        item_category: 'Kitchen',
        item_variant: 'Sage',
        price: 16.00,          // unit price after any discount
        quantity: 4
      }
    ]
  }
});

The purchase is the same shape with three more fields, pushed on the confirmation page once the order exists:

window.dataLayer.push({ ecommerce: null });
window.dataLayer.push({
  event: 'purchase',
  ecommerce: {
    transaction_id: 'WEB-30917',   // the order number, unique per order
    value: 64.00,
    tax: 12.80,
    shipping: 3.95,
    currency: 'GBP',
    items: [{ item_id: 'MUG-STONE-01', item_name: 'Stoneware mug', price: 16.00, quantity: 4 }]
  }
});

The rules, from Google’s Tag Manager guide and events reference:

  • event is the GA4 event name, lowercase. add_to_cart, not AddToCart or basket_add. The trigger listens for this.
  • Every ecommerce field sits inside ecommerce. That’s the object Send Ecommerce data reads. Every push in Google’s Tag Manager guide keeps the fields there.
  • value and price are numbers. No quotes, no £ sign. value is the sum of price times quantity, without tax or shipping.
  • currency is a three-letter code such as GBP, at event level. Google marks it required whenever value is set.
  • Each item has item_id or item_name. Google recommends both.
  • Each item has price and quantity. quantity defaults to 1, and item revenue needs the price. price is the unit price after discount. The per-unit discount goes in discount.
  • The same item_id for a product on every event. GA4 reports items by the ID and name you send. A SKU on view_item and a database ID on purchase read as two products.
  • Send every field you have. Google’s guide says to set each parameter you have data for, optional or not: brand, up to five category levels, variant, coupon.

transaction_id is what stops double counting. GA4 drops a second purchase carrying an ID it has already received. A reload of the confirmation page counts once. A plugin sending the same order with exactly the same ID to the same property should too. A copy with no ID or a different one, such as a checkout token instead of the order number, counts again: F-101 , covered in GA4 purchase event fires twice.

A field you invent, such as size, is allowed on items (up to 27 per item). It won’t show in reports until it’s registered as an item-scoped custom dimension. That gap is F-601 .

Why push ecommerce: null before every ecommerce event?

Every ecommerce example in Google’s Tag Manager guide does it, with the comment “Clear the previous ecommerce object”. The reason: GTM keeps what each push adds until something overwrites it. Google’s open-source data-layer-helper library describes the model GTM’s data layer follows: objects merge key by key, arrays position by position.

Worked through on a category page, without the clear:

  1. The page pushes view_item_list with three products in items, and item_list_name: 'Kitchen' on the event.
  2. The shopper adds one product. The site pushes add_to_cart with one item.
  3. The new item merges into position 0. Positions 1 and 2 still hold the other two products from the list.
  4. The tag sends add_to_cart with three items. The event-level item_list_name carries over too.

Nothing errors. The basket report is just wrong. In GTM Preview it shows on the Data Layer tab: more items on add_to_cart than the shopper added. One line before each push stops it:

window.dataLayer.push({ ecommerce: null });

Pushing null replaces the object outright, so the next push starts from empty.

How do I set up GA4 ecommerce tracking in GTM: the tag and trigger

Before you start: the Google tag with your G- measurement ID loads on every page (Initialization, All Pages). Then:

  1. Tags, New, Google Analytics: GA4 Event. Measurement ID: the same G- ID.
  2. Event Name: {{Event}}. The built-in variable passes through whichever event name the push carried. That’s the step from Google’s guide. It’s what lets one tag cover the whole funnel.
  3. More Settings, Ecommerce: tick Send Ecommerce data, Data Source: Data Layer. No need to map ecommerce fields in Event Parameters; this option sends them.
  4. One trigger: Custom Event, Use regex matching ticked. Regex is a pattern match. List the event names your site pushes. For the four core events:
^(view_item|add_to_cart|begin_checkout|purchase)$

Add the other names inside the brackets, separated by |, as the site starts pushing them.

Google’s guide leaves the trigger to you. This single-trigger pattern is mine. Two details stop it misfiring.

  • ^ and $ stop partial matches. GTM’s regex is a partial match: Google’s own example matches any URL containing the pattern. Without the anchors, purchase_confirmed from some other script fires the tag too.
  • Lowercase names. Purchase and purchase are different events to the trigger. Keep the pushes lowercase.

The alternative Google documents is one tag per event, each on a Custom Event trigger named after it. It works. It’s a dozen tags to keep in step instead of one. If you map fields by hand from Data Layer Variables, set each one to Version 2. Version 1 reads ecommerce.items as one name with a dot in it, and finds nothing.

Which ecommerce events does a shop push, and when?

Push each event when the thing has happened, with the products involved. Adds that fail (out of stock, a validation error) shouldn’t count, so add_to_cart goes on the basket’s confirmation, not on the button click. A push that runs before the product data exists is a timing fault, F-103 .

EventPush whenKey event-level fields
view_item_lista product list showsitem_list_id, item_list_name
select_itema listed product is clickeditem_list_id, item_list_name
view_itema product page loadscurrency, value
add_to_cartthe basket confirms the addcurrency, value
remove_from_cartan item leaves the basketcurrency, value
view_cartthe basket page loadscurrency, value
begin_checkoutcheckout openscurrency, value, coupon
add_shipping_infodelivery is chosencurrency, value, shipping_tier
add_payment_infopayment method is chosencurrency, value, payment_type
purchasethe order existstransaction_id, currency, value, tax, shipping
refundan order is refundedtransaction_id, currency, value
The GA4 ecommerce push sheet · when each event fires and its key fields · build reference, from Google's events reference, not a client account

The full list per event, with optional fields such as coupon and customer_type, is in Google’s events reference. Every row carries an items array except refund, where it’s optional: a full refund can go with the transaction ID alone. value on view_item doesn’t count towards revenue. Google lists it anyway; send it.

Google’s guide also covers view_promotion and select_promotion, for shops running on-site banners or offers, and add_to_wishlist. Add them if the site has those features, and add their names to the trigger.

How do I test the dataLayer before it goes live?

  1. GTM Preview. Walk the funnel: a list, a product, add to basket, checkout, a test order. In the Tag Assistant timeline, click each ecommerce event.
  2. Data Layer tab. The fields sit inside ecommerce, value and price show without quotes, and items holds only the products of that step.
  3. Tags tab. The GA4 Event tag fired on that event, once.
  4. GA4 DebugView, GA4’s live test view. Admin, Data display, DebugView. Open purchase: transaction_id, value and currency among the parameters, and an Items tab listing every line with its price.
  5. A new transaction ID for every test order. A repeated ID is dropped as a duplicate, which looks like a broken tag.
  6. Two days after go-live, the GA4-only check at the top of this note.

An event in DebugView that is still missing from the ecommerce reports after 48 hours: check it against the events reference. Is value a number, is currency there, are there items, did it go to the right G- ID? Google says an event missing a required field is treated as a custom event, not an ecommerce one. The diagnosis note covers the rest.

Plugin or hand-built dataLayer?

On WooCommerce, Magento and similar platforms, a plugin often writes the pushes. The checks are the same: read what it pushes in GTM Preview before trusting it. Event names, numbers as numbers, the clear before each push. What Magento and BigCommerce send before you add anything is in GA4 on Magento and BigCommerce.

Two things to watch:

  • A plugin that also sends to GA4 itself. A purchase from both should count once only if both send exactly the same transaction ID to the same property; compare the IDs in DebugView rather than rely on it. Every other event they both send, add_to_cart and the rest, counts twice. Pick one sender.
  • An old Universal Analytics shape. A push holding ecommerce.purchase.actionField and products is the retired format. Google’s GA4 guides document only the shape above. Build to that.

Common questions

How do I set up GA4 ecommerce tracking with GTM?

The site’s code pushes each shop event to the dataLayer, fields inside ecommerce, with ecommerce: null just before. In GTM, one GA4 Event tag (Event Name {{Event}}, Send Ecommerce data on, Data Source Data Layer) on a Custom Event trigger matching those event names.

Why does Google push ecommerce: null before every ecommerce event?

GTM merges each push into what is already on the page, item by item. Without the clear, products and list fields from an earlier step carry into the next event.

Do I need a separate GTM tag for each ecommerce event?

No. One tag with Event Name {{Event}} sends whichever event the push names, on one regex Custom Event trigger anchored with ^ and $.

Which ecommerce events should a shop push to GA4?

At minimum view_item, add_to_cart, begin_checkout and purchase. Then view_item_list, select_item, view_cart, remove_from_cart, add_shipping_info, add_payment_info and refund where the site supports them.

Who sets up the GA4 ecommerce dataLayer: a developer or the GTM person?

Both. The pushes are site code or a plugin; the tag and trigger are GTM work. If your developer writes the pushes but nobody owns the container, the tags, triggers and the test before go-live are the part I take on as a Google Tag Manager consultant.

How do I test the GA4 ecommerce dataLayer before go-live?

Walk the funnel in GTM Preview and read each event’s Data Layer tab, then check the same events in DebugView. New transaction ID on every test order.

Sources

Read on 7 November 2026:

  • Google for Developers, Measure ecommerce, Tag Manager version (GA4 Event tag with Event Name {{Event}}; More Settings, Ecommerce, Send Ecommerce data, Data Source Data Layer; the per-event alternative with Data Layer Variables such as ecommerce.items and Custom Event triggers; dataLayer.push({ ecommerce: null }) commented “Clear the previous ecommerce object” before every example push; the event set including promotions and wishlist; items array up to 200 elements; one of item_id or item_name, both recommended; quantity defaults to 1; up to 27 custom item parameters; currency at event level when sending value; set each parameter you have data for; refund with transaction_id, item information recommended for item-level refund metrics)
  • Google for Developers, GA4 recommended events reference (fields per event, including shipping_tier, payment_type, coupon and customer_type; currency required if value is set; value as the sum of price times quantity, excluding shipping and tax; value on view_item doesn’t contribute to revenue; price as the discounted unit price, discount as the unit discount; items optional on refund)
  • Google for Developers, Set up a purchase event (purchase on the confirmation page; verify in DebugView)
  • Google for Developers, Validate your ecommerce setup (DebugView Items tab; a missing required parameter makes Analytics treat the event as a custom event; a repeated ecommerce event with one transaction ID keeps only the first) and Google Analytics Help, Minimise duplicate key events with transaction IDs (Analytics deduplicates purchase events with the same transaction ID)
  • Google for Developers, The data layer (values persist for the current page; a push with an existing name overwrites it; push with an event name and listen with a Custom Event trigger) and Google, data-layer-helper (abstract data model: array onto array and plain object onto plain object recursively merge; other values, null included, overwrite)
  • Google Tag Manager Help, Regex and CSS selector operators (matches regex; the example pattern matches any URL containing it) and user-defined variable types (Data Layer Variable Version 1 keeps dots in key names, Version 2 reads them as nested values)
  • Shopify Help Center, Checkout Extensibility upgrade guide (additional scripts view-only since 28 August 2025; upgrading the Thank you and Order status pages replaces existing customisations; tracking moves to app pixels; non-Plus deadline 26 August 2026) and Custom pixels (custom pixels run in a sandbox and collect customer events on pages including checkout)
  • Google Analytics Help, data freshness (reports can take 24 to 48 hours to process)

← back to the reading room