SiteTidy
HomeGuidesGoogle Tag Manager Event Tracking (Part 3): Ecommerce That You Can Trust
Analytics

Google Tag Manager Event Tracking (Part 3): Ecommerce That You Can Trust

Build reliable GA4 ecommerce tracking with Google Tag Manager: item arrays, cart and checkout events, purchase deduplication, refunds, revenue accuracy and production QA.

Published on August 15, 2026Updated August 31, 2026
Google Tag Manager Event Tracking (Part 3): Ecommerce That You Can Trust

Ecommerce tracking has an awkward property: it can look healthy while being financially wrong.

GA4 may show purchases. Your dashboards may contain revenue. The marketing team may be happily calculating ROAS. Yet a refresh of the confirmation page can count a second purchase, tax may be mixed into one implementation and excluded from another, a stale items array can attach the wrong product to an event, or a frontend race can fire purchase before the transaction ID exists.

That is why ecommerce measurement should be treated less like “adding some GTM tags” and more like a small financial data pipeline.

The goal of this part is to build that pipeline deliberately.

Start with the commercial journey, not the GA4 interface

A useful ecommerce model describes meaningful changes in the customer’s journey:

Product list shown
    ↓
Product selected
    ↓
Product viewed
    ↓
Added to cart
    ↓
Checkout started
    ↓
Shipping/payment steps
    ↓
Purchase confirmed
    ↓
Refunded, partially or fully

GA4 already defines recommended ecommerce events for most of these actions. Prefer those names and their documented parameters when they describe what actually happened.

Typical events include:

  • view_item_list
  • select_item
  • view_item
  • add_to_cart
  • remove_from_cart
  • view_cart
  • begin_checkout
  • add_shipping_info
  • add_payment_info
  • purchase
  • refund
  • view_promotion
  • select_promotion

Do not invent product_clicked_v2 when select_item already means what you need. Standard semantics make implementation, reporting and future maintenance easier.

But equally, do not fire an event simply because GA4 offers it. An event should correspond to a real business occurrence.

The application should know what was bought

A recurring analytics mistake is asking GTM to reconstruct commerce state from rendered HTML.

For example, a tag scrapes:

  • the product name from an <h1>;
  • price from .price;
  • quantity from an input;
  • category from breadcrumbs.

This works until the design changes, localisation alters the price string, an A/B test moves an element or a component renders asynchronously.

Your commerce application already knows the SKU, quantity, price and transaction ID. Publish that information as structured data instead.

<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ ecommerce: null });
window.dataLayer.push({
  event: 'add_to_cart',
  ecommerce: {
    currency: 'GBP',
    value: 79.98,
    items: [{
      item_id: 'TSHIRT-001-BLK-L',
      item_name: 'Heavyweight T-Shirt',
      item_brand: 'Example Co',
      item_category: 'Clothing',
      item_variant: 'Black / Large',
      price: 39.99,
      quantity: 2
    }]
  }
});
</script>

That payload is a contract between the application and measurement layer.

GTM should route and transform the contract where necessary. It should not become an unreliable second implementation of your shopping cart.

Why clear the ecommerce object?

Google’s current Tag Manager examples commonly clear the previous ecommerce object before pushing a new ecommerce event:

dataLayer.push({ ecommerce: null });

Then they push the new event and ecommerce payload.

The reason is state. GTM’s data model can retain values from previous pushes. If one event contains fields that the next event omits, careless implementations can accidentally expose stale ecommerce values to later tags.

A clear-and-push pattern makes each ecommerce event more self-contained:

dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: 'begin_checkout',
  ecommerce: {
    currency: 'GBP',
    value: 119.97,
    items: cartItems
  }
});

Do not interpret this as permission to spray arbitrary resets throughout the site. Establish one documented ecommerce contract and implement it consistently.

The items array is the centre of GA4 ecommerce

GA4 ecommerce is item-oriented. Products or services are represented by objects inside items.

A useful item might look like this:

{
  "item_id": "SKU-1842",
  "item_name": "Trail Running Shoe",
  "item_brand": "North Ridge",
  "item_category": "Footwear",
  "item_category2": "Running",
  "item_variant": "Blue / UK 9",
  "price": 89.95,
  "quantity": 1
}

Google requires at least item_id or item_name for the recommended ecommerce model. In a serious implementation, use a stable product identifier whenever one exists.

Names change. SKUs normally should not.

Price and quantity need an agreed meaning

Do not leave teams to infer what price means.

Document whether the value represents:

  • unit price after item-level discount;
  • VAT-inclusive or VAT-exclusive price;
  • settlement currency or display currency;
  • subscription initial charge or recurring amount.

Google’s ecommerce guidance treats item price as unit price and supports a separate item-level discount field. Your application and finance reporting should agree with the measurement definition.

value and currency belong together

If you send monetary value, send the currency.

{
  currency: 'GBP',
  value: 149.97
}

A bare number such as 149.97 has no financial meaning without its currency.

For item-based ecommerce events, calculate value consistently from the relevant item values rather than scraping a formatted total from the page.

For example:

const merchandiseValue = items.reduce(
  (total, item) => total + (item.price * item.quantity),
  0
);

Do not casually mix shipping and tax into merchandise value if your reporting contract says they are separate. The purchase event has dedicated shipping and tax parameters.

A production-quality purchase event

The purchase is the event where small mistakes become expensive.

A representative payload is:

dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: 'purchase',
  ecommerce: {
    transaction_id: 'ORD-2026-004821',
    currency: 'GBP',
    value: 149.97,
    tax: 25.00,
    shipping: 4.99,
    coupon: 'SUMMER10',
    items: [
      {
        item_id: 'SKU-1001',
        item_name: 'Merino Base Layer',
        item_brand: 'Example Co',
        item_category: 'Clothing',
        price: 49.99,
        quantity: 3
      }
    ]
  }
});

The important field is not the prettiest one in the report. It is transaction_id.

Purchase deduplication is not optional

Imagine the thank-you page fires purchase on every page load.

A customer:

  1. completes an £800 order;
  2. reaches /order/complete;
  3. refreshes the page;
  4. bookmarks it;
  5. opens it again later.

If every render becomes a new purchase, your revenue reporting is fiction.

GA4 uses transaction_id to help avoid duplicate purchase events. Supply a stable, unique transaction identifier from the order system.

But do not stop there.

The strongest design is to make the application itself understand whether a transaction has already been emitted to a particular measurement pipeline. That matters when the same purchase can be generated by browser code, a server-side integration, retries or multiple confirmation routes.

The general rule is:

The identity of a purchase should come from the commerce system, not from the browser session.

Do not generate a random transaction ID in GTM.

Fire purchase when the order exists

A click on “Pay now” is not a purchase.

Neither is:

  • opening the payment modal;
  • submitting card details;
  • redirecting to a payment provider;
  • receiving a frontend success animation before backend confirmation.

Fire purchase when your system has sufficiently authoritative confirmation that the transaction exists.

Depending on the architecture, that may be:

  • the server-rendered order confirmation;
  • application state populated from a confirmed order API;
  • a server-side event after payment/order finalisation.

This distinction becomes particularly important with asynchronous payment methods.

Client-side and server-side purchase measurement

Browser-side GTM is convenient because it has rich session and attribution context. Server-side systems are closer to the transaction truth.

Neither automatically makes the other wrong.

For high-value measurement, think explicitly about the source of truth.

A common architecture is:

Browser journey events
        │
        ├── view_item
        ├── add_to_cart
        └── begin_checkout

Commerce backend
        │
        └── confirmed order/payment
                 │
                 └── authoritative purchase signal

If both browser and server send the same conversion, design deduplication deliberately. “We’ll probably only receive one” is not a strategy.

Checkout steps should describe actual progress

begin_checkout should mean the customer entered checkout, not merely that a checkout button became visible.

Likewise:

add_shipping_info

should represent meaningful shipping information being supplied or confirmed, and:

add_payment_info

should correspond to the relevant payment stage.

These events are useful because they let you find where users abandon the funnel. If they are fired from arbitrary UI interactions, the funnel becomes impossible to interpret.

Product lists need context

view_item_list and select_item are much more useful when you retain the list context.

For example:

dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: 'select_item',
  ecommerce: {
    item_list_id: 'search_results',
    item_list_name: 'Search Results',
    items: [{
      item_id: 'SKU-1842',
      item_name: 'Trail Running Shoe',
      index: 4,
      price: 89.95,
      quantity: 1
    }]
  }
});

Now you can distinguish a product selected from:

  • search results;
  • a category page;
  • related products;
  • a recommendation rail;
  • a campaign landing page.

Without that context, “product click” tells you much less.

Be careful with impressions

List impression tracking can generate huge volumes of events.

Decide what “viewed” means.

Does an item count when:

  • it exists in the HTML?
  • the carousel slide is created?
  • it enters the viewport?
  • at least half of it is visible?
  • it remains visible for a minimum duration?

There is no universally correct product rule. The important thing is that the definition is consistent and useful.

For long lists and virtualised interfaces, firing an impression for every item instantiated by JavaScript can badly overstate exposure.

Promotions have the same problem

view_promotion should not necessarily mean “the promotion component exists somewhere in the DOM”.

If the business wants to measure actual exposure, use a sensible visibility definition. Then use select_promotion for the corresponding interaction.

Record stable promotion identifiers and placement information where useful.

Refunds deserve first-class tracking

Revenue does not end at purchase.

If returns materially affect the business, implement refund.

A full refund can identify the transaction:

dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: 'refund',
  ecommerce: {
    transaction_id: 'ORD-2026-004821',
    currency: 'GBP',
    value: 149.97
  }
});

For partial refunds, include the affected items and quantities where your implementation supports the necessary detail.

The source should normally be your order/refund system rather than a browser page that somebody may never visit.

Ecommerce is where server-to-server measurement becomes valuable

Some commercial events happen when no browser is present:

  • a payment settles later;
  • an invoice is paid;
  • a subscription renews;
  • a refund is processed by support;
  • an offline sale is associated with a digital lead.

GA4 provides server-to-server collection mechanisms for appropriate use cases. That does not mean you should copy every browser event to the server. It means measurement architecture should follow where the business event actually occurs.

Keep privacy, consent and platform requirements in the design rather than treating server-side collection as a way around them.

Do not send personal data because it is convenient

The checkout contains exactly the fields that analytics implementations are most tempted to leak:

  • email address;
  • full name;
  • telephone number;
  • postal address;
  • free-text delivery instructions.

Do not casually push these into the data layer or analytics parameters.

The data layer is observable in the browser, and downstream tags may receive values you expose there.

Use business-safe identifiers and dimensions that are actually required for measurement.

GTM configuration: keep it boring

A maintainable GTM ecommerce implementation often has:

  1. one Custom Event trigger per meaningful event or a carefully designed shared pattern;
  2. Data Layer Variables for the required ecommerce fields;
  3. GA4 event tags that map the contract predictably;
  4. clear naming;
  5. documented exceptions.

Avoid a container full of tags named:

GA event NEW
GA event NEW 2
purchase fixed
purchase fixed final
purchase final v3

Operational quality matters because analytics code lives for years.

Test values, not just firing

GTM Preview showing a green “Tag Fired” indicator proves surprisingly little.

For each ecommerce event, inspect the actual payload.

For purchase, verify at least:

  • correct event name;
  • real transaction ID;
  • expected currency;
  • correct value definition;
  • tax and shipping semantics;
  • item IDs;
  • item names;
  • item prices;
  • quantities;
  • discounts/coupons where applicable;
  • exactly one logical transaction.

Then validate downstream collection with GA4 debugging/realtime tools and network inspection where appropriate.

Test hostile user journeys

The happy path is the easiest path to get right.

Try these instead:

  • refresh the order confirmation page;
  • press Back then Forward;
  • open the confirmation URL in another tab;
  • buy two units of the same item;
  • apply and remove a coupon;
  • change currency;
  • buy a discounted variant;
  • remove the final cart item;
  • abandon and resume checkout;
  • fail payment then retry;
  • use an asynchronous payment method;
  • partially refund an order;
  • fully refund it;
  • navigate through the flow in an SPA without full reloads.

These tests expose the difference between tracking that fires and tracking that is correct.

Reconcile analytics against commerce data

For purchase measurement, create a regular reconciliation process.

Compare, over the same time window:

Commerce platform
- order count
- gross merchandise value
- refunds

Analytics
- purchase transactions
- purchase revenue
- refunds

They will not necessarily match perfectly. Consent, blockers, time zones, attribution rules, server failures and processing differences can all matter.

The point is to understand the gap.

A sudden move from a 5% difference to a 35% difference is an operational signal.

Treat schema changes like API changes

Suppose developers rename:

product_id → sku

or change:

price: 39.99

to:

price: "£39.99"

The visual website may work perfectly while analytics silently degrades.

Version-control the measurement specification alongside the application where possible. Include analytics requirements in feature acceptance criteria for checkout changes.

A practical ecommerce QA checklist

Before publishing:

  • Recommended GA4 ecommerce event names are used where appropriate.
  • Events correspond to genuine business actions.
  • Product data comes from application state, not fragile DOM scraping.
  • Ecommerce state cannot leak between events.
  • Stable item IDs are present.
  • value and currency are consistent.
  • Purchase uses the real transaction ID.
  • Refresh/navigation cannot manufacture additional orders.
  • Tax, shipping and discount definitions are documented.
  • Refund behaviour is designed.
  • PII is excluded from analytics payloads.
  • Consent behaviour is tested.
  • SPA routes are tested if applicable.
  • Actual payload values are inspected in QA.
  • Analytics revenue is periodically reconciled with the commerce system.

Audit the site around your measurement stack

Analytics quality depends on the surrounding website too. SiteTidy can inspect the public-facing site for technical, performance and configuration issues while you validate the analytics implementation itself.

Run Free Audit →

The principle to keep

A purchase event is not a marketing pixel firing on a thank-you page. It is a measurement representation of a financial event.

Design it with roughly that level of care.

When transaction identity, item data, monetary semantics, refunds, deduplication and QA are treated as a coherent contract, ecommerce analytics becomes something teams can make decisions from rather than a collection of attractive numbers that nobody quite trusts.

In Part 4, we’ll tackle consent and privacy: what Consent Mode actually does, how to establish defaults and updates correctly, and why server-side tagging does not remove your privacy obligations.

Ready to audit your site?

Put this guide into practice immediately using our free tools.

Browse 180+ Free Tools