Skip to content
Faisal Mahmud TusherDigital marketing, SEO & analytics
with Faisal Tusher

Marketing Analytics › Google Analytics 4

E-commerce Tracking in GA4

A step-by-step GA4 e-commerce tutorial: the recommended events, the items array, the data layer contract, GTM tags, currency and value, and deduplication.
Tutorialadvanced11 min readUpdated

Before you start

  • The data layer in place. The data layer guide is the first prerequisite: the shop's developers need to be able to push structured objects to the data layer on each template before the tag fires.
  • Events and parameters understood. The events and parameters guide is the second: how GA4 events carry parameters, which parameters are collected automatically, and the difference between an event parameter and an item parameter.
  • One implementation route. Decide whether the shop will use this Tag Manager approach, a direct Google tag implementation, or a platform's native integration. Use one. Many wrong revenue figures come from two routes running together.
  • A product field inventory. For each template (listing, product, basket, checkout, confirmation), write down which product attributes the page can expose: identifier, name, brand, category, variant, price, and whether the price shown includes tax.
  • A test environment and a test order. Tag Manager preview and GA4 DebugView work on production, but a staging site and a way to place and refund a real test order make the purchase step safe to check.
  • Agreement on currency and value. Pick the currency code the site will send and decide once whether event values include tax and shipping; the developer guide's convention is item price times quantity, with tax and shipping sent in their own parameters.
  1. Map the shopping funnel to the recommended events

    Walk the shop as a customer and note each stage: a category or search listing, a product page, the basket, the start of checkout, the shipping and payment stages, the confirmation page, and the refund process in the back office. Each stage maps to a documented GA4 event, listed in the reference table below. The listing and product templates are the same ones the category and product pages guide describes from the search side, which helps when asking developers where in the template code each push belongs. Decide now which events are in scope for the first release. A sensible minimum is product view to purchase; promotions, wishlists and the basket view can follow once the core set is verified.

  2. Agree the items array contract

    Every e-commerce event carries an items array, and every object in it uses the same documented fields: item_id or item_name (one is required, send both), plus item_brand, item_category and its numbered siblings, item_variant, price, quantity, discount, coupon, index, item_list_id, item_list_name and location_id where they apply. Write this as a one-page contract with the developers: the source of each field in the catalogue, the format of the identifier (the same SKU or product ID everywhere, never the name on one template and the SKU on another), the price as a plain number in the agreed currency, and the quantity as a whole number. Consistency matters more than completeness, because item reports group on these values and a brand spelled two ways becomes two brands.

  3. Instrument listings with view_item_list and select_item

    On category pages, search results and any carousel of products, push view_item_list with the list's item_list_id and item_list_name and the items shown, each with its index position. When a shopper clicks a product in the list, push select_item with the same list identifiers and the single item chosen. These two events power the item list reports, which show which placements lead to views and purchases. Lists that render more items as the shopper scrolls should push additional view_item_list events for the newly rendered batch rather than one event for the whole page, and the list name should be the merchandising name a buyer recognises, not a template identifier.

  4. Instrument the product page with view_item

    On the product detail template, push view_item with currency, value set to the item price, and an items array containing the product with as many of the contract fields as the page can supply. If the page has variant selectors, decide whether a variant change pushes a new view_item or updates the data layer silently; the developer guide treats a view as a view of the page, and in practice one event per page load with the default variant is the cleaner choice. Make sure the push happens before the Tag Manager container evaluates the trigger; a push that lands after the page view has fired is lost unless it is tied to its own event name, which is why the data layer guide insists on pushing an event key.

  5. Track basket changes with add_to_cart and remove_from_cart

    Push add_to_cart when a product is added, with currency, value as the price times the quantity added, and the item with its quantity. Push remove_from_cart symmetrically when a line is removed or its quantity reduced, with the quantity removed. Quantity changes inside the basket are the usual source of errors: an increment from one to two should send an add of one, not an add of two. If the basket page itself is a meaningful stage for the business, push view_cart with the full contents. These events drive the purchase journey report's add-to-basket step and the item-level "added to basket" metric, so an implementation that only tracks the product page's add button and misses the quick-add on listings will understate the step.

  6. Mark the start of checkout with begin_checkout

    On the first checkout page, or when the checkout button is clicked for a single-page checkout, push begin_checkout with currency, value as the basket's item total, the items array of the whole basket, and coupon if a code is already applied. This is the first step of the checkout journey report and the point from which checkout abandonment is measured. Guest and signed-in flows should both fire it; a flow that sends the event only after login hides the people who leave at the login wall. If the checkout is hosted on another domain, cross-domain measurement must be configured in the data stream before this step, or the session will restart and the funnel will show checkout starting from Referral.

  7. Add the checkout stages with add_shipping_info and add_payment_info

    Push add_shipping_info when the shopper submits a delivery method, carrying shipping_tier with the chosen option, and add_payment_info when a payment method is chosen, carrying payment_type. Both include the same currency, value and items as the checkout start. These two events complete the checkout journey report, which then shows where between shipping, payment and purchase the shop loses people. Avoid firing them on page load of the shipping and payment steps if the shopper has not yet made a choice; fire on the action. Where the checkout is a single page with sections, fire each event when its section is completed, which usually means on the continue button rather than on field blur.

  8. Send purchase with a transaction identifier

    On the confirmation page, push purchase with transaction_id set to the order number, currency, value as the order's item total, tax, shipping, coupon and affiliation where relevant, and the full items array with final prices and quantities. The identifier is documented as the field that helps GA4 avoid counting a purchase twice; treat it as a safety net rather than a licence to fire on every reload, because event counts and downstream destinations such as a Google Ads import can still see the repeat. Guard the push server-side or with a flag so a refreshed confirmation page, a bookmarked one or a return from a payment provider does not send the order again. The value convention and the identifier set here are what GA4's average order value is built from, as the glossary entry on AOV in GA4 explains. Keep test orders out of production or filter them by a developer traffic rule. Once revenue flows, the ROAS calculator turns the purchase values and campaign spend into the ROAS figures the media team will ask for.

  9. Record refunds

    Refunds usually happen in the back office rather than in the browser, which makes refund the event most implementations skip. For a full refund, send refund with the original transaction_id, currency and value; for a partial refund, include the items array with only the refunded lines and quantities. Because there is no page to push from, this event is often sent through the Measurement Protocol from the order management system, or batched daily by a developer; both are legitimate as long as the identifier matches the original purchase. Without refunds, GA4 revenue overstates the shop's net figure permanently and the CVR by campaign looks better than the finance team's view. Decide early whether refunds are in scope and document the choice in the contract if they are not.

  10. Build the Tag Manager tag and trigger

    In the container, create one GA4 event tag whose event name is read from the built-in Event variable, so the data layer's event key becomes the GA4 event name unchanged. Enable the tag's option to send e-commerce data with the data layer as the source, which makes the tag read the ecommerce object and forward items, currency, value and the other parameters without mapping each one by hand. Create a custom event trigger whose event name matches the e-commerce event names, either listed or with a regular expression, and attach it. Before each push, the site should push ecommerce: null to clear the previous object so fields from an earlier event do not leak into the next; the data layer guide explains why the merge behaviour makes this necessary. Publish to a workspace, not straight to live, and test in preview.

  11. Verify in DebugView and the reports

    Open Tag Manager preview and walk the journey from listing to purchase with a test order. At each stage, confirm the data layer tab shows the push with the expected items, that the GA4 tag fired once and only once, and that the outgoing request carries the item fields. Then open GA4 DebugView, select the debug device, and inspect each event's parameters and items; a missing field is usually a template that does not expose it rather than a tag problem. Place and refund a test order and check purchase and refund arrive with the same identifier. After processing, read the ecommerce purchases report for the item rows, the purchase journey and checkout journey reports for the funnel steps, and reconcile a closed day against the shop's order list; if that day does not reconcile, the guide to GA4 revenue that does not match the shop's orders sorts the differences by cause. The conversion analytics hub covers what to do with the funnel once it is trustworthy.

Event reference table

EventWhen it firesKey parametersReport it feeds
view_promotion / select_promotionA promotion banner is shown or clickedpromotion_id, promotion_name, creative_name, creative_slot, itemsPromotions report
view_item_listA list of products is rendereditem_list_id, item_list_name, items with indexItem list performance
select_itemA product is clicked in a listitem_list_id, item_list_name, one itemItem list performance
view_itemA product page is viewedcurrency, value, itemsEcommerce purchases (items viewed), purchase journey
add_to_wishlistA product is saved for latercurrency, value, itemsItem metrics
add_to_cart / remove_from_cartA line is added to or removed from the basketcurrency, value, items with quantityPurchase journey, items added to basket
view_cartThe basket page is viewedcurrency, value, itemsPurchase journey (optional step)
begin_checkoutCheckout startscurrency, value, coupon, itemsPurchase journey, checkout journey
add_shipping_infoA delivery option is chosenshipping_tier, currency, value, itemsCheckout journey
add_payment_infoA payment method is chosenpayment_type, currency, value, itemsCheckout journey
purchaseThe order is confirmedtransaction_id, currency, value, tax, shipping, coupon, itemsRevenue, transactions, item revenue, all funnels
refundAn order is refunded in full or in parttransaction_id, currency, value, items for partialRefund metrics
Illustrative example — not a real result

Two pushes from a bicycle retailer's templates

A bicycle shop's product template pushes view_item for a gravel bike priced at £1,250, and its confirmation page pushes purchase for an order of that bike plus two inner tubes at £6.50 each, with £12 shipping and £252.60 tax (20% of the item total) recorded separately, with no discount code applied. The value on the purchase is the item total of £1,263.00, following the developer guide's convention, and the order number GB-204417 is the transaction_id. The pushes below are what the developers ship; the clearing push before each one stops the tubes from appearing on the next product view. In DebugView the purchase shows two item rows (three units) and one transaction_id, and the ecommerce purchases report lists the bike with item revenue of £1,250 and the tubes with £13 the following day.

window.dataLayer = window.dataLayer || [];
dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: "view_item",
  ecommerce: {
    currency: "GBP",
    value: 1250.00,
    items: [{
      item_id: "BK-GRV-56",
      item_name: "Ridgeline Gravel Bike",
      item_brand: "Ridgeline",
      item_category: "Bikes",
      item_category2: "Gravel",
      item_variant: "56cm / Slate",
      price: 1250.00,
      quantity: 1
    }]
  }
});
dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: "purchase",
  ecommerce: {
    transaction_id: "GB-204417",
    currency: "GBP",
    value: 1263.00,
    tax: 252.60,
    shipping: 12.00,
    items: [
      { item_id: "BK-GRV-56", item_name: "Ridgeline Gravel Bike", item_brand: "Ridgeline", item_category: "Bikes", item_category2: "Gravel", item_variant: "56cm / Slate", price: 1250.00, quantity: 1 },
      { item_id: "TB-700-32", item_name: "Inner Tube 700x32", item_brand: "Ridgeline", item_category: "Parts", price: 6.50, quantity: 2 }
    ]
  }
});

When orders arrive in the shop but no purchases or no revenue reach the property, the diagnosis on a GA4 purchase event that is not tracking follows a test order from the push to the report. Once the events are verified, the guide to product and merchandising analysis in GA4 reads the item lists, promotions and product funnels they produce.

Verify it worked

  • Walk the journey from listing to purchase in Tag Manager preview. Each stage should show one data layer push with the expected items, and the GA4 tag should fire once.
  • Open DebugView after a test order. The purchase should show every ordered line and one transaction_id, as in the bicycle example.
  • Compare the purchase value with the item total. Tax and shipping should sit in their own parameters.
  • Reload the confirmation page. No second purchase should appear. Then refund the test order and confirm refund arrives with the same identifier.
  • After processing, read the purchase and checkout journey reports. A closed day should reconcile with the shop's order list.

If it goes wrong

  • Revenue is double the shop's order total. Two implementation routes are probably running, or the purchase is resent on reload. Keep one route and guard the push.
  • The item reports show two products for one. Identifiers probably differ between templates. Use the same SKU or product ID everywhere.
  • An event carries items from the previous event. The ecommerce: null clear is probably missing. Push it before every e-commerce event.
  • The funnel shows checkout starting from Referral. The checkout is probably on another domain. Configure cross-domain measurement in the data stream.
  • A field is missing in DebugView. The template may not expose it, or the push landed late. Ask the developers to expose it and keep the event key.

Next steps

Common mistakes

  • Two implementations at once. A platform integration and a Tag Manager tag both sending purchase doubles revenue from day one.
  • Different identifiers per template. A SKU on the product page and a database ID at checkout make the item reports show two products for one.
  • Purchase on page load without a guard. Reloads, bookmarks and payment-provider returns resend the order.
  • Value conventions that drift. Tax in on one template and out on another; pick the convention and write it down.
  • Missing the ecommerce: null clear. Items from the previous event leak into the next push.
  • Checkout on another domain without cross-domain setup. The funnel restarts from Referral at checkout.
  • Skipping refunds. Revenue overstates the net figure for ever.
  • Verifying only in preview. DebugView and a reconciled closed day against the order list are the test that counts; the GA4 hub links the debugging and checklist pages that make that routine.

Frequently asked questions

Do I need every recommended e-commerce event, or just purchase?

Purchase alone gives revenue and transactions, but none of the funnel reports. The purchase journey and checkout journey reports need view_item, add_to_cart, begin_checkout and the checkout-stage events to show where people drop out. Implement the full set from product view to purchase if the shop wants to improve conversion, and add promotions and lists later when the first set is clean.

Why does GA4 revenue not match the shop's own order total?

The common causes are a purchase event that fires again when the confirmation page is reloaded, test orders reaching the production property, value sent including or excluding tax and shipping inconsistently, a currency code that does not match the shop, and refunds recorded in one system but not the other. Reconcile a closed week order by order once, and the cause is usually obvious.

Can I send e-commerce events without Tag Manager?

Yes. The developer guide shows the same events sent directly with the Google tag, and some commerce platforms have a native GA4 integration that sends them for you. Whichever route you choose, use only one; a native integration plus a Tag Manager implementation sends every event twice, and the data layer contract described here still applies if you want the fields to be consistent.

Terms used on this page

Tools to try

Where this page is used

Part of these learning paths

Also related

Sources

  1. Measure ecommerce (GA4 developer guide) — Google Analytics Developers
  2. Google Analytics Help — Google Analytics Help

Related