Home / Guides

GA4 ecommerce dataLayer: check every push

A purchase push can fire every tag and still report the wrong revenue. What GA4 requires of each ecommerce event, a purchase push that meets it, and the mistakes to look for before it ships.

GTM accepts almost any push. A purchase with the price written as text, the shipping folded into the total and no currency fires the GA4 tag exactly as a correct one does. The difference turns up weeks later, as revenue that does not match the shop’s own numbers.

The rules are short and they are all Google’s. What follows is each one, and the push it applies to.

The events and what each one needs

From Google’s ecommerce reference for Tag Manager. Required means the event is incomplete without it.

EventRequired
purchasetransaction_id, items, and value with currency. Optional: coupon, shipping, tax, customer_type.
refundtransaction_id
add_payment_infoitems (optional: payment_type)
add_shipping_infoitems (optional: shipping_tier)
begin_checkoutitems
add_to_cart, remove_from_cartitems
add_to_wishlistitems
view_cart, view_itemitems
select_item, view_item_listitems

Two more, view_promotion and select_promotion, carry promotion details and are left out here. Across all of them, one rule holds: if an event sets value, it sets currency too.

Each item needs one of item_id or item_name (Google recommends both). The rest is optional: price, quantity, discount, coupon, item_brand, item_category to item_category5, item_variant, item_list_id, item_list_name, index, affiliation and location_id.

A purchase push that passes

dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: 'purchase',
  ecommerce: {
    transaction_id: 'T-1001',
    value: 188.80,
    tax: 37.76,
    shipping: 4.95,
    currency: 'EUR',
    items: [
      { item_id: 'SKU-11', item_name: 'Stone pillow', price: 49.90, quantity: 2 },
      { item_id: 'SKU-27', item_name: 'Linen throw', price: 89.00, quantity: 1 }
    ]
  }
});

The numbers agree: 49.90 × 2 plus 89.00 × 1 is 188.80, the value. Tax and shipping sit beside it, not inside it. Every price and quantity is a number, and both items have an id and a name.

The first line clears the previous ecommerce object. GTM does not read the array of pushes; it keeps a merged state built from all of them, so a key the new push does not set keeps the value an earlier push gave it. A coupon from an add_to_cart can end up on the purchase that way. The dataLayer inspector page covers the difference between the array and what GTM reads.

In GTM the paths are the ones a Data Layer Variable takes: ecommerce.value, ecommerce.transaction_id, ecommerce.items. Shops that push their own event names rather than GA4’s need the mapping first; the guide to dataLayer dialects has it.

The mistakes to check, one rule each

A correct push is half of it. The tag that reads it can still send something else: a variable pointed at ecommerce.items.0.price instead of ecommerce.value, or no currency mapped at all. Check the push, then check the request it produced.

Checking it in Tag Master

The extension’s Events panel records every push in order, including the ones made while the page loads, checks each one against the GA4 ecommerce schema and shows a score with its recommendations. Each push is flattened into the paths a GTM variable reads, and listed beside the requests it set off, with what each request left out compared with the push.

Without the extension, the free tools cover the same ground one request at a time. The tracking request decoder takes the GA4 hit and runs the extension’s rules on it: currency codes, transaction IDs on purchases, items with no id or name, prices that are not numbers, and a value that does not match its items. For purchases sent from your server, the Measurement Protocol validator checks the JSON body before it goes to GA4.

Questions

Should the GA4 purchase value include shipping and tax?

No. Google defines value as the sum of price × quantity for all items and says not to include shipping or tax. Those go in their own shipping and tax parameters on the purchase.

What happens if I send value without currency?

Google’s reference says currency is required if you set value, so that revenue metrics can be computed accurately. Send the three-letter code, such as EUR, on every event that carries a value.

Does every item need an item_id?

Each item needs at least one of item_id or item_name, and Google recommends sending both. An item with neither is the one to fix first.

How many items can one GA4 ecommerce event carry?

Up to 200 elements in the items array, and up to 27 custom parameters per item on top of the ones Google prescribes.

Why is my GA4 purchase counted twice?

Most often the confirmation page was loaded twice: a reload, a back-navigation, or a checkout that renders again. Send transaction_id on every purchase, then read the two hits side by side to tell a reload from two tags.

The rest of this group: Shops and their data layers

More in Shops and their data layers

Try it on your own site

Tag Master is free, needs no account, and collects no data.

Add to Chrome, it’s free