Analytics & Tracking

GA4 eCommerce Tracking: The Events and Data Layer Every Store Needs

Set up GA4 ecommerce tracking that holds up: the recommended events, the items array, a clean purchase event, the data layer and how to QA it on Shopify.

TL;DR
  • GA4 has a fixed set of recommended eCommerce events, from view_item_list to purchase and refund. Use Google's exact event and parameter names, or the built-in eCommerce reports stay empty.
  • The items array is the backbone: the same item_id, item_name, price and category structure has to appear in every event, from product view to purchase, or funnel and product reports won't join up.
  • Build the data layer from your platform's real order and cart data, push one event per action, and QA every event in DebugView and against real test orders before you trust a single report.

What should GA4 eCommerce tracking tell you?

Google Analytics 4 (GA4) only knows what your site tells it. Every product view, add to cart and purchase has to arrive as an event with the right name and data. That is event tracking, and for eCommerce Google defines the vocabulary in advance. Start from the questions the business needs answered:

  • Which products and collections get viewed but rarely added to cart?
  • Where in checkout do shoppers drop off: shipping, payment or the final step?
  • Which promotions, product lists and recommendation blocks drive revenue?
  • How much revenue comes from new versus returning customers?
  • How much is refunded, and on which products?

If your setup can’t answer one of them, that is the gap to close first.

Which GA4 eCommerce events should every store send?

Google’s recommended eCommerce events cover the path from browsing to refunds. Use the names exactly as written; GA4 doesn’t treat variants such as “addToCart” as eCommerce events.

Event When it fires Key parameters Priority
view_item_list A collection, search results or recommendation block is shown item_list_id, item_list_name, items Should have
select_item A shopper clicks a product in a list item_list_name, items Should have
view_item A product page is viewed currency, value, items Must have
add_to_cart An item is successfully added to the cart currency, value, items Must have
remove_from_cart An item is removed currency, value, items Should have
view_cart The cart page or drawer opens currency, value, items Should have
begin_checkout Checkout starts currency, value, coupon, items Must have
add_shipping_info Shipping step is completed shipping_tier, items Should have
add_payment_info Payment step is completed payment_type, items Should have
purchase The order is confirmed transaction_id, value, currency, tax, shipping, coupon, items Must have
refund An order is refunded, fully or partly transaction_id, value, currency, items Must have
view_promotion An internal banner or promo is shown promotion_id, promotion_name, creative_slot Nice to have
select_promotion An internal promo is clicked promotion_id, promotion_name Nice to have
add_to_wishlist An item is saved to a wishlist currency, value, items Nice to have

Google also recommends a search event with a search_term parameter for on-site search. On most stores it’s worth adding alongside the list above.

What goes in the items array?

Almost every eCommerce event carries an items array, and most broken setups break here. Each item needs item_id or item_name (Google recommends both), and an event can carry up to 200 items.

Parameter What to send Common mistake
item_id One consistent ID: SKU or variant ID Product ID on view_item, SKU on purchase
item_name The product title Including the variant in the name
item_variant Size, color or other option Left empty, so variant reporting is lost
item_category to item_category5 Your category hierarchy, top level first Collection names that change with campaigns
price Unit price after any item discount Price before discount, or price × quantity
discount Unit discount amount Total order discount spread onto one item
quantity Number of units Missing, so it defaults to 1
coupon Item-level code, if any Mixed up with the order-level coupon
item_list_name and index List name and position Only sent on the list view, not carried to the add to cart

Google’s definition of price is specific: if a discount applies to the item, set price to the discounted unit price and send the unit discount in the discount parameter.

Pick item_id once and use it everywhere. Ideally it matches the ID in your product feed, so GA4, Google Ads and Google Merchant Center all talk about the same product.

What should a correct purchase event contain?

The purchase event is the one your revenue reports, ad imports and bidding depend on. Google marks transaction_id as required and notes that it helps you avoid duplicate purchase events. If you send value, you must also send currency.

Two details trip up most setups:

  • What goes in value. Google’s reference says to set value to the sum of price × quantity for all items, without shipping or tax, which go in their own parameters. Document your choice, because Shopify’s sales reports define revenue differently. Our guide to the GA4 and Shopify revenue gap explains how to compare like for like.
  • New versus returning. The optional customer_type parameter takes new or returning. Google recommends a 540-day lookback by default and says not to set it when you’re unsure, such as on unmatched guest checkouts. It’s the cheapest way to separate new-customer revenue in GA4.

Here is what a clean purchase push looks like in a data layer (illustrative values):

dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: "purchase",
  ecommerce: {
    transaction_id: "1042",
    value: 118.00,
    tax: 9.44,
    shipping: 6.00,
    currency: "USD",
    coupon: "WELCOME10",
    customer_type: "new",
    items: [
      {
        item_id: "MER-CREW-NVY-M",
        item_name: "Merino Crew Sock",
        item_variant: "Navy / M",
        item_category: "Socks",
        price: 18.00,
        discount: 2.00,
        quantity: 2
      },
      {
        item_id: "MER-HAT-GRY",
        item_name: "Merino Beanie",
        item_variant: "Gray",
        item_category: "Accessories",
        price: 82.00,
        quantity: 1
      }
    ]
  }
});

Check the math: 18.00 × 2 + 82.00 × 1 = 118.00, which matches value.

How do you build the data layer?

The data layer is a JavaScript object your site fills with structured data, which Google Tag Manager (GTM) reads and sends to GA4. Five rules keep it reliable:

  1. Clear before every push. Google’s GTM guide pushes ecommerce: null before each eCommerce event, so old values don’t carry over.
  2. One push per action, after it succeeds. Fire add_to_cart when the cart confirms the item was added, not on the button click.
  3. Use platform data, not the page. Pull prices, IDs and quantities from the cart or order object. Scraping page text breaks with every theme change.
  4. Guard the purchase. Use the order ID so a refreshed confirmation page doesn’t send a second purchase.
  5. Send eCommerce data from the tag. In a GTM GA4 Event tag, turn on “Send Ecommerce data” under More Settings, with Data Layer as the source.

Consent

With consent mode, Google tags adjust to each visitor’s consent choice instead of firing regardless. If you sell to the EU or UK, read our guide to Consent Mode v2, and confirm your setup with counsel.

How does this work on Shopify, WooCommerce and Magento?

Shopify. Checkout tracking runs through Shopify’s customer events. You can let the Google & YouTube app send GA4 events, or write a custom pixel that subscribes to Shopify’s standard events and forwards them to GA4 or GTM. Use one source for purchases, not both. Shopify’s standard event names map to GA4 like this:

Shopify standard event GA4 event
collection_viewed view_item_list
product_viewed view_item
search_submitted search
product_added_to_cart add_to_cart
product_removed_from_cart remove_from_cart
cart_viewed view_cart
checkout_started begin_checkout
checkout_shipping_info_submitted add_shipping_info
payment_info_submitted add_payment_info
checkout_completed purchase

Two events aren’t in Shopify’s standard list. select_item and promotion events need theme-level data layer pushes. Refunds happen in the admin, not the browser, so send them server-side, for example through the GA4 Measurement Protocol or a connector that reads Shopify refunds. Many teams also route events through a GTM server container; our guide to server-side tagging for Shopify covers when that pays off.

WooCommerce. A tracking plugin or custom code pushes events to the data layer. Test whichever checkout you use, classic or block-based, check that caching doesn’t serve a stale confirmation page, and make sure off-site gateways return shoppers to the order-received page.

Magento / Adobe Commerce. An extension or custom module usually builds the data layer. Watch full-page caching, and check that multi-store setups send the right currency.

How do you QA GA4 eCommerce tracking?

Run this list after every theme, checkout or cart-related app change:

  • [ ] Every event in the table fires once, with the exact Google name, in GTM preview or Tag Assistant.
  • [ ] GA4 DebugView shows the items array on each event, with the same item_id from view_item through purchase.
  • [ ] Price, quantity and value add up on add_to_cart, begin_checkout and purchase.
  • [ ] Ten real test orders, including a discount code and a multi-item cart, appear in GA4 once each with the right transaction_id.
  • [ ] A refreshed confirmation page doesn’t create a second purchase.
  • [ ] A full and a partial refund reach GA4 and show in refund reports.
  • [ ] Events respect consent choices: decline on the banner and check what still fires.
  • [ ] Monetization reports in GA4 show product names, categories and list names, not “(not set)”.

A clean setup won’t make GA4 match your store’s orders exactly, but it makes the gap stable and explainable. To see what tracking gaps cost you before rebuilding anything, start with the Free Profit Audit.

FAQ

Do I need Google Tag Manager for GA4 eCommerce tracking?

No. You can use gtag.js directly, an app such as Shopify’s Google & YouTube app, or a custom pixel. GTM helps when several platforms need the same events or you want to change tags without editing theme code.

Should GA4 purchase value include shipping and tax?

Google’s events reference says value should be the sum of price × quantity for the items, without shipping or tax, which go in their own parameters. Whatever definition you use, document it and compare GA4 against your store data on the same basis.

Why do my GA4 eCommerce reports show “(not set)” for product names?

Usually because an event was sent without an items array, or with parameter names GA4 doesn’t recognize. Check the event in DebugView, confirm the items array is present, and compare the parameter names against Google’s reference.

Turn this into a plan for your store

The Free Profit Audit scans your store, sizes your biggest profit leaks and builds a 90-day plan.

Free Profit Audit