E-commerce

E-commerce tracking in GA4: get started fast

Learn how to set up Google Analytics 4 e-commerce tracking. Configure purchase events, product views, and the complete shopping funnel.

A
Antoine
January 14, 20267 min read

E-commerce tracking in GA4 is more powerful than in Universal Analytics, but the setup is different. Let me walk you through getting it working quickly.

What e-commerce tracking gives you

With proper setup, you'll see:

  • Product performance: Which products get viewed, added to cart, purchased
  • Shopping funnel: Where customers drop off
  • Revenue data: Total revenue, average order value, transactions
  • Purchase behavior: Repeat customers, cart abandonment

All of this feeds into GA4's monetization reports and lets you create valuable audiences.

The e-commerce events

GA4 uses specific event names for e-commerce. Use these exact names to unlock enhanced e-commerce reports.

Core funnel events

EventWhen to fire
view_itemProduct page view
add_to_cartAdd product to cart
remove_from_cartRemove product from cart
view_cartView cart page
begin_checkoutStart checkout process
add_payment_infoEnter payment details
add_shipping_infoEnter shipping details
purchaseComplete transaction

Additional useful events

EventWhen to fire
view_item_listView product list/category page
select_itemClick on product in a list
view_promotionSee a promotion banner
select_promotionClick on promotion
refundProcess a refund

The items array

Every e-commerce event needs an items array with product details:

items: [
  {
    item_id: "SKU_12345",
    item_name: "Premium T-Shirt",
    affiliation: "Online Store",
    coupon: "SUMMER20",
    discount: 5.00,
    index: 0,
    item_brand: "YourBrand",
    item_category: "Clothing",
    item_category2: "T-Shirts",
    item_category3: "Men",
    item_list_id: "related_products",
    item_list_name: "Related Products",
    item_variant: "Blue / Large",
    price: 24.99,
    quantity: 1
  }
]

You don't need all fields, so focus on what you can reliably provide:

FieldRequired?Notes
item_id✅ YesUnique product identifier (SKU)
item_name✅ YesProduct name
price✅ YesUnit price
quantity✅ YesNumber of items
item_brandRecommendedBrand name
item_categoryRecommendedPrimary category
item_variantRecommendedSize, color, etc.
couponOptionalApplied coupon code
discountOptionalDiscount amount

Implementation methods

Option 1: Direct dataLayer (recommended)

Push events to the dataLayer, then use GTM to forward to GA4.

Step 1: Push product data when users interact

// Product page view
dataLayer.push({ ecommerce: null });  // Clear previous data
dataLayer.push({
  event: "view_item",
  ecommerce: {
    currency: "USD",
    value: 24.99,
    items: [{
      item_id: "SKU_12345",
      item_name: "Premium T-Shirt",
      price: 24.99,
      quantity: 1
    }]
  }
});
// Add to cart
dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: "add_to_cart",
  ecommerce: {
    currency: "USD",
    value: 24.99,
    items: [{
      item_id: "SKU_12345",
      item_name: "Premium T-Shirt",
      price: 24.99,
      quantity: 1
    }]
  }
});
// Purchase
dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: "purchase",
  ecommerce: {
    transaction_id: "T_12345",
    value: 49.98,
    tax: 4.50,
    shipping: 5.99,
    currency: "USD",
    coupon: "SUMMER20",
    items: [{
      item_id: "SKU_12345",
      item_name: "Premium T-Shirt",
      price: 24.99,
      quantity: 2
    }]
  }
});

Step 2: Create GTM tags for each event

For each e-commerce event:

  1. Create a Custom Event trigger matching the event name
  2. Create a GA4 Event tag:
    • Event name: Same as dataLayer event
    • Use Send Ecommerce Data option (if available in your GTM version)
    • Or map parameters manually from {{DLV - ecommerce.value}}, etc.

Option 2: Platform plugins

If you're on a major platform, plugins can handle this:

PlatformSolution
ShopifyBuilt-in GA4 integration, or enhanced plugins
WooCommerceMonsterInsights, GTM4WP, or similar
MagentoGoogle Analytics extension
BigCommerceBuilt-in GA4 integration

Plugins vary in quality. Some only track purchases, missing the full funnel. Always verify what events are actually firing.

Option 3: gtag.js directly

If you're not using GTM:

gtag('event', 'purchase', {
  transaction_id: 'T_12345',
  value: 49.98,
  tax: 4.50,
  shipping: 5.99,
  currency: 'USD',
  items: [{
    item_id: 'SKU_12345',
    item_name: 'Premium T-Shirt',
    price: 24.99,
    quantity: 2
  }]
});

Essential purchase event data

The purchase event is most critical. Here's what you need:

{
  transaction_id: "T_12345",    // Required: unique order ID
  value: 49.98,                 // Required: total order value
  currency: "USD",              // Required: 3-letter currency code
  tax: 4.50,                    // Recommended
  shipping: 5.99,               // Recommended
  coupon: "SUMMER20",           // Optional: order-level coupon
  items: [/* array of items */] // Required: what was bought
}

Critical: transaction_id must be unique. Duplicate IDs = double-counted revenue.

Verifying your setup

DebugView check

  1. Enable GA Debugger extension or use GTM Preview Mode
  2. Go to GA4 → Admin → DebugView
  3. Complete a test purchase
  4. Watch for view_item, add_to_cart, begin_checkout, purchase events
  5. Click each event to verify parameters are populated

Key things to verify

CheckHow
Events fire at right timeWalk through purchase flow in DebugView
Items array is populatedClick event, expand parameters, find items
Value and currency presentCheck value and currency parameters
No duplicate transactionsUse unique transaction_id
Correct pricesVerify value matches actual cart total

Monetization reports

After 24-48 hours:

  1. Go to Reports → Monetization
  2. Check E-commerce purchases report
  3. Verify revenue matches your actual sales

Common mistakes

Wrong currency format

// Wrong
currency: "$"

// Right
currency: "USD"

Use ISO 4217 currency codes (USD, EUR, GBP, etc.).

Prices as strings

// Wrong
price: "24.99"

// Right
price: 24.99

Prices and values should be numbers, not strings.

Missing items array

The items array is required for most e-commerce events. Without it, you lose product-level insights.

Not clearing ecommerce object

Always clear before pushing new ecommerce data:

dataLayer.push({ ecommerce: null }); // Clear first
dataLayer.push({
  event: "add_to_cart",
  ecommerce: { /* data */ }
});

Otherwise, data from previous events can leak through.

Firing purchase on cart page

Only fire purchase when the transaction is complete and confirmed. Usually after payment success, not on checkout pages.

Marking key events

Don't forget to mark purchase as a key event:

  1. Go to Admin → Events
  2. Find purchase
  3. Toggle Mark as key event ON

This is crucial if you're importing conversions to Google Ads.

For more on key events, see our conversion tracking guide.

Quick setup checklist

Basic funnel:

  • view_item on product pages
  • add_to_cart on add-to-cart action
  • begin_checkout on checkout start
  • purchase on order confirmation

Enhanced funnel (optional but valuable):

  • view_item_list on category pages
  • select_item on product clicks
  • view_cart on cart page
  • remove_from_cart on item removal
  • add_shipping_info on shipping step
  • add_payment_info on payment step

Configuration:

  • purchase marked as key event
  • Tested in DebugView
  • Verified in Monetization reports

What's next?

Once basic e-commerce tracking works:

  1. Set up Shopify-specific tracking if applicable
  2. Configure enhanced funnel analysis
  3. Build e-commerce dashboards

If you want a simpler way to monitor your e-commerce performance, try Analayer. We make your GA4 revenue data clear and actionable.

See your analytics clearly

Stop struggling with Google Analytics. Connect your account and get a cleaner, simpler view of your data in seconds.