EN DE
Get a Free Audit

GA4 E-Commerce Tracking Setup: A Complete Implementation Guide

Set up GA4 e-commerce tracking correctly. Learn the required events, data layer structure, GTM configuration, and mistakes that break revenue reporting.

E-commerce tracking in GA4 is different from Universal Analytics, and migration isn’t straightforward. Many e-commerce sites have GA4 installed but aren’t collecting the data they need. This guide covers proper implementation from start to finish.

Key Takeaways

  • Four events are essential — At minimum, implement view_item, add_to_cart, begin_checkout, and purchase before adding anything else.
  • Use a data layer — A JavaScript data layer separates product data from tracking logic, making implementation cleaner and easier to debug.
  • Always clear the ecommerce object — Push { ecommerce: null } before each new event to prevent data bleed between events.
  • Test before going live — Use GTM Preview mode and GA4 DebugView to verify every event fires with correct parameters.

Why GA4 E-Commerce Tracking Matters

Without proper e-commerce tracking, you’re flying blind:

  • You can’t see which products drive revenue
  • You can’t calculate true ROAS in Google Ads
  • You can’t identify where users drop off in the purchase funnel
  • You can’t analyze customer behavior by product category or price point

GA4’s e-commerce tracking gives you the data to answer these questions—but only if it’s implemented correctly.

GA4 E-Commerce Events Overview

GA4 uses a predefined set of e-commerce events. You don’t have to use all of them, but certain events are essential:

Required Events

EventWhen to FirePurpose
view_itemUser views a product pageProduct interest tracking
add_to_cartUser adds item to cartCart behavior analysis
begin_checkoutUser starts checkoutFunnel analysis
purchaseTransaction completesRevenue and conversion tracking
EventWhen to FirePurpose
view_item_listUser views category/collection pageProduct discovery patterns
select_itemUser clicks a product from a listClick-through from lists
remove_from_cartUser removes item from cartCart abandonment analysis
add_shipping_infoUser enters shipping detailsCheckout step tracking
add_payment_infoUser enters payment detailsCheckout step tracking

Optional Events

EventWhen to FirePurpose
view_cartUser views cart pageCart page engagement
view_promotionUser sees a promotion bannerPromotion effectiveness
select_promotionUser clicks a promotionPromotion click-through
refundTransaction is refundedRevenue accuracy

Priority: Get the four required events working first. Add others as needed.

The Data Layer Approach

The cleanest implementation uses a data layer—a JavaScript object that your website populates with product data, which GTM then reads.

What Is the Data Layer?

The data layer is a JavaScript array that stores structured data:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: 'view_item',
  ecommerce: {
    currency: 'EUR',
    value: 59.99,
    items: [{
      item_id: 'SKU-12345',
      item_name: 'Blue Running Shoes',
      item_brand: 'Nike',
      item_category: 'Shoes',
      price: 59.99,
      quantity: 1
    }]
  }
});

When this code runs on your product page, it pushes the product data to the data layer. GTM listens for the view_item event and sends it to GA4 with all the item details.

Why Use the Data Layer?

Separation of concerns: Your developers populate the data; your analytics setup reads it. Changes to tracking don’t require code deploys.

Consistency: All platforms (GA4, Google Ads, Meta) can read from the same data layer.

Debugging: You can inspect the data layer in browser developer tools to verify data before it’s sent.

Required Parameters for Each Event

GA4 expects specific parameters with each e-commerce event. Here’s what’s required:

view_item

dataLayer.push({
  event: 'view_item',
  ecommerce: {
    currency: 'EUR',
    value: 29.99,
    items: [{
      item_id: 'SKU-001',
      item_name: 'Product Name',
      price: 29.99,
      quantity: 1
    }]
  }
});

add_to_cart

dataLayer.push({
  event: 'add_to_cart',
  ecommerce: {
    currency: 'EUR',
    value: 29.99,
    items: [{
      item_id: 'SKU-001',
      item_name: 'Product Name',
      price: 29.99,
      quantity: 1
    }]
  }
});

begin_checkout

dataLayer.push({
  event: 'begin_checkout',
  ecommerce: {
    currency: 'EUR',
    value: 89.97,
    items: [
      {
        item_id: 'SKU-001',
        item_name: 'Product 1',
        price: 29.99,
        quantity: 1
      },
      {
        item_id: 'SKU-002',
        item_name: 'Product 2',
        price: 59.98,
        quantity: 2
      }
    ]
  }
});

purchase

dataLayer.push({
  event: 'purchase',
  ecommerce: {
    transaction_id: 'T-12345',
    value: 89.97,
    tax: 14.99,
    shipping: 5.99,
    currency: 'EUR',
    items: [
      {
        item_id: 'SKU-001',
        item_name: 'Product 1',
        price: 29.99,
        quantity: 1
      },
      {
        item_id: 'SKU-002',
        item_name: 'Product 2',
        price: 29.99,
        quantity: 2
      }
    ]
  }
});

Critical: The transaction_id on purchase events must be unique. Duplicate transaction IDs will be deduplicated by GA4.

Optional Item Parameters

Enhance your reporting with additional item parameters:

ParameterDescription
item_brandProduct brand
item_categoryPrimary category
item_category2Sub-category
item_category3Sub-sub-category
item_variantSize, color, etc.
discountDiscount amount applied
couponCoupon code used

GTM Configuration

Step 1: Create Data Layer Variables

In GTM, create variables to read from the data layer:

Variable: Ecommerce Items

  • Type: Data Layer Variable
  • Name: ecommerce.items

Variable: Ecommerce Value

  • Type: Data Layer Variable
  • Name: ecommerce.value

Variable: Ecommerce Currency

  • Type: Data Layer Variable
  • Name: ecommerce.currency

Variable: Transaction ID

  • Type: Data Layer Variable
  • Name: ecommerce.transaction_id

Step 2: Create Triggers

Create custom event triggers for each e-commerce event:

Trigger: view_item

  • Type: Custom Event
  • Event name: view_item

Trigger: add_to_cart

  • Type: Custom Event
  • Event name: add_to_cart

Trigger: begin_checkout

  • Type: Custom Event
  • Event name: begin_checkout

Trigger: purchase

  • Type: Custom Event
  • Event name: purchase

Step 3: Create GA4 Event Tags

For each event, create a GA4 Event tag:

Tag: GA4 - view_item

  • Type: Google Analytics: GA4 Event
  • Configuration Tag: [Your GA4 Configuration Tag]
  • Event Name: view_item
  • Event Parameters:
    • currency: {{Ecommerce Currency}}
    • value: {{Ecommerce Value}}
    • items: {{Ecommerce Items}}
  • Trigger: view_item

Repeat for add_to_cart, begin_checkout, and purchase.

For the purchase event, add additional parameters:

  • transaction_id: {{Transaction ID}}
  • shipping: {{Ecommerce Shipping}}
  • tax: {{Ecommerce Tax}}

Step 4: Clear Ecommerce Object

Important: Clear the ecommerce object before each push to prevent data bleeding between events:

dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: 'add_to_cart',
  ecommerce: {
    // ... your data
  }
});

Or create a single tag in GTM that fires on all e-commerce events and sets ecommerce: null first.

Always clear the ecommerce object before each push. Without pushing { ecommerce: null } first, previous event data bleeds into subsequent events and corrupts your reporting.

Platform-Specific Implementation

Shopify

Shopify’s native GA4 integration handles basic tracking, but for complete e-commerce data:

  1. Use Shopify’s built-in Google channel for basic setup
  2. For enhanced tracking, use a dedicated app like Elevar or Analyzify
  3. Custom implementations require Shopify’s Customer Events API (requires development)

WooCommerce

Several plugins handle GA4 e-commerce:

  • GTM4WP: Free, reliable, includes data layer output
  • Pixel Manager for WooCommerce: More features, includes server-side support
  • MonsterInsights: User-friendly but limited flexibility

Manual implementation requires hooking into WooCommerce actions and outputting data layer pushes.

Custom Platforms

For custom e-commerce platforms:

  1. Work with your development team to output data layer pushes on relevant pages
  2. Ensure product data is available server-side or via API
  3. Test thoroughly in staging before production

Testing and Debugging

Preview Mode Testing

  1. Enable GTM Preview mode
  2. Navigate through your site: product page → add to cart → checkout → purchase
  3. Verify each event fires with correct data

In Preview mode, click each event and expand the “Data Layer” tab to see the exact data being passed.

GA4 DebugView

  1. In GA4, go to Admin → DebugView
  2. Enable debugging in GTM (check “Enable debug mode” in your GA4 Config tag)
  3. Watch events appear in real-time as you trigger them

DebugView shows you exactly what GA4 receives, including all parameters.

Common Testing Scenarios

Test these scenarios before going live:

ScenarioWhat to Verify
Single product purchaseAll item data correct, transaction_id unique
Multi-product purchaseAll items included, value totals correctly
Product with variantsVariant data captured
Purchase with discountDiscount or coupon captured
Guest checkoutEvents still fire without user login
Returning customerNo duplicate transactions

Google Tag Assistant

Install the Tag Assistant Chrome extension for real-time tag debugging. It shows all GA4 events being sent and flags potential issues.

Verify revenue totals match your order system. After 24-48 hours of data collection, compare GA4 revenue with your e-commerce platform's records to catch discrepancies early.

Common Mistakes That Break Reporting

Missing or Incorrect Currency

If currency is missing or wrong, GA4 can’t properly aggregate revenue. Verify currency is passed with every event that includes a value.

Duplicate Transactions

If your thank-you page can be refreshed or bookmarked, the purchase event may fire multiple times. Solutions:

  • Use session storage to track if purchase was already sent
  • Implement server-side tracking that only fires once per transaction
  • Use transaction_id deduplication (GA4 dedupes automatically if IDs match)

Items Array Format

The items parameter must be an array, even for single products. This is wrong:

items: { item_id: 'SKU-001' }  // Wrong - object

This is correct:

items: [{ item_id: 'SKU-001' }]  // Correct - array

Value Mismatch

The value parameter should match the sum of item prices × quantities. Mismatches confuse reporting.

Missing Data Layer Clear

Without clearing the ecommerce object between pushes, previous event data bleeds into subsequent events. Always push { ecommerce: null } before each new event.

Price as String

Prices should be numbers, not strings:

price: '29.99'  // Wrong - string
price: 29.99    // Correct - number

Firing on Page Load Instead of Action

add_to_cart should fire when the user clicks “Add to Cart,” not when the page loads with items already in the cart.

Verifying Data in GA4

After implementation, verify data flows correctly:

Real-Time Report

Go to Reports → Real-time and look for your e-commerce events. You should see view_item, add_to_cart, etc., appearing as you test.

Monetization Reports

After 24-48 hours of data collection, check:

  • Monetization → E-commerce purchases: Transaction and revenue data
  • Monetization → Checkout journey: Funnel from view to purchase

E-commerce Data Quality Checklist

  • Revenue totals match your order system
  • Product names display correctly
  • Categories are populated and consistent
  • Transaction IDs are unique
  • Currency is correct

Integration with Google Ads

Proper GA4 e-commerce tracking enables:

  • Import conversions to Google Ads for optimization
  • Calculate true ROAS based on actual revenue
  • Build audiences based on purchase behavior
  • Dynamic remarketing with product feeds

For Google Ads conversion tracking best practices, see our GA4 reporting checklist.

Server-Side Considerations

For improved data quality, consider server-side tracking:

  • More reliable than browser-based tracking (immune to ad blockers)
  • Better data for conversion APIs (Google, Meta)
  • Required for accurate iOS tracking post-ATT

For server-side implementation details, see our server-side tracking guide.

Get Help with E-Commerce Tracking

E-commerce tracking is one of the most complex analytics implementations. Done wrong, you have unreliable data and flawed optimization signals.

If you’re seeing discrepancies between GA4 and your e-commerce platform, missing revenue data, or broken funnel reports, contact us for a tracking audit.

We’ll diagnose your current setup, identify gaps, and implement tracking that actually works—so you can trust the data driving your decisions.

For broader GA4 reporting setup, we can ensure your entire analytics foundation is solid.

Sources

  1. GA4 e-commerce event reference — Google Analytics Help
  2. Recommended events for e-commerce — Google Analytics Help
  3. Google Tag Manager data layer documentation — Google Developers
47 points
Free Download

Google Ads Audit Checklist

The exact checklist we use to audit Google Ads accounts. 47 points covering account structure, tracking, bidding, and creative.

Need help with your performance marketing?

Book a free consultation and let's discuss your goals.