AttriModel
BlogE-commerce Purchase Event Tracking in GA4
GA48 min read·April 23, 2026

E-commerce Purchase Event Tracking in GA4

The purchase event is the most important conversion in e-commerce analytics. Here is how to implement it correctly and what to do when numbers look wrong.

A

AttriModel Team

AttriModel Team

Why Purchase Tracking Is Complex

Purchase tracking seems simple — fire an event when an order is confirmed. In practice, it is the most error-prone implementation in e-commerce analytics because:

  • The confirmation page can be seen multiple times (back button, shared URL)
  • Payment processors redirect through external domains before returning
  • AJAX checkout flows don't trigger standard page loads
  • Test orders inflate your data during development

The GA4 Purchase Event Schema

`javascript

window.dataLayer.push({

'event': 'purchase',

'ecommerce': {

'transaction_id': 'T-12345', // REQUIRED: unique, used for deduplication

'affiliation': 'Google Store', // Optional

'value': 142.50, // REQUIRED: revenue value

'tax': 12.00, // Optional

'shipping': 5.99, // Optional

'currency': 'USD', // REQUIRED

'coupon': 'SUMMER20', // Optional

'items': [{ // REQUIRED: at least one item

'item_id': 'SKU_001',

'item_name': 'Running Shoes',

'affiliation': 'Nike',

'coupon': '',

'discount': 0,

'index': 0,

'item_brand': 'Nike',

'item_category': 'Footwear',

'item_variant': 'Blue/42',

'price': 59.99,

'quantity': 1

}]

}

});

`

Preventing Duplicate Purchases

The most critical issue: never fire the purchase event more than once per order.

Option 1: Session Storage Flag

`javascript

const orderId = 'T-12345';

if (!sessionStorage.getItem(order_tracked_${orderId})) {

sessionStorage.setItem(order_tracked_${orderId}, 'true');

window.dataLayer.push({event: 'purchase', ecommerce: {transaction_id: orderId, ...}});

}

`

Option 2: Server-Side Deduplication

Track server-side using GA4 Measurement Protocol and only fire the browser event if the server hasn't already recorded it.

Verifying Your Purchase Tracking

  • Make a test purchase (use a payment method that can be refunded)
  • In GTM Preview: confirm the purchase event fires on the confirmation page
  • In GA4 DebugView: verify the purchase event appears with correct value and items
  • Check GA4 Reports → Monetization → Ecommerce purchases within 24 hours

When Numbers Don't Match Your Platform

Expect a 5-15% discrepancy between GA4 and your Shopify/WooCommerce order dashboard due to:

  • Users who close before the confirmation page loads
  • Order fraud that was cancelled post-confirmation
  • Returns and refunds (use GA4's refund event to correct)

If your discrepancy exceeds 20%, investigate duplicate purchases or broken tracking first.

GA4E-commercePurchase TrackingGTM