How to Set Up GA4 E-commerce Tracking with Google Tag Manager

How to Set Up GA4 E-commerce Tracking with Google Tag Manager

This guide is detailed. But if you follow it step by step, you will end up with a working e-commerce tracking setup in GA4. We will focus on implementation, not reporting.

TL;DR – Quick Summary

  • GA4 requires manual e-commerce implementation (Enhanced Measurement does not cover it)
  • Key events: view_item, add_to_cart, begin_checkout, purchase
  • Push events to data layer with the ecommerce object
  • Clear ecommerce object before each push to prevent data leakage
  • Enable “Send E-commerce data” in your GA4 tags

What You Will Learn

In this guide, you will learn:

  1. What e-commerce events GA4 expects
  2. How to structure your data layer
  3. How to configure tags and triggers in GTM
  4. How to verify everything works in DebugView

Why Default Tracking Is Not Enough

If you rely only on Enhanced Measurement, you will miss critical e-commerce interactions. GA4 does not automatically track product views, add-to-cart actions, or purchases. You need to implement these events manually.

Prerequisites

  • Google Tag Manager installed on your site
  • GA4 property created
  • Access to your website code (or a developer who can help)
  • Basic understanding of the data layer

Step 1: Define Your E-commerce Events

GA4 expects specific event names for e-commerce. The most important ones are:

  • view_item — when a user views a product page
  • add_to_cart — when a user adds a product to cart
  • begin_checkout — when a user starts checkout
  • purchase — when a transaction completes

Event names are case-sensitive. Use exactly the names GA4 expects. Purchase is not the same as purchase.

Step 2: Push Events to the Data Layer

Your website needs to push e-commerce data to the data layer. Here is an example for a purchase event:

dataLayer.push({
  event: "purchase",
  ecommerce: {
    transaction_id: "T12345",
    value: 99.99,
    currency: "USD",
    items: [{
      item_id: "SKU123",
      item_name: "Product Name",
      price: 99.99,
      quantity: 1
    }]
  }
});

Clear the ecommerce object before pushing a new event. This prevents data from previous events leaking into the next one.

dataLayer.push({ ecommerce: null });
dataLayer.push({
  event: "purchase",
  ecommerce: { ... }
});

Step 3: Create Variables in GTM

Now, let us configure GTM to read the e-commerce data.

  1. Go to GTM → Variables → New
  2. Choose Data Layer Variable
  3. Set the variable name to ecommerce.items
  4. Save the variable

Repeat this for other parameters you need, such as ecommerce.transaction_id and ecommerce.value.

Step 4: Create a Custom Event Trigger

Next, create a trigger that fires when the purchase event occurs.

  1. Go to GTM → Triggers → New
  2. Choose Custom Event
  3. Enter purchase as the event name
  4. Save the trigger

Step 5: Create the GA4 Event Tag

Finally, create a tag that sends the event to GA4.

  1. Go to GTM → Tags → New
  2. Choose GA4 Event
  3. Select your GA4 Configuration tag
  4. Set the event name to purchase
  5. Under E-commerce, check “Send E-commerce data”
  6. Set Data source to “Data Layer”
  7. Attach your purchase trigger
  8. Save the tag

The “Send E-commerce data” checkbox is crucial. Without it, your e-commerce parameters will not be sent to GA4.

Step 6: Test Your Implementation

Do not publish immediately. First, verify everything works.

  1. GTM Preview mode: Click Preview in GTM, then trigger a test purchase on your site. Confirm the tag fires.
  2. GA4 DebugView: Go to GA4 → Admin → DebugView. You should see the purchase event with all parameters.
  3. Check parameters: Verify that transaction_id, value, currency, and items appear correctly.

If you do not see the event in DebugView, first check whether your tag fires in Preview mode. If it does not, the trigger is the issue. If the tag fires but nothing appears in GA4, check your Measurement ID.

Common Mistakes

Avoid these common pitfalls:
  • Using wrong event names (e.g., “Purchase” instead of “purchase”)
  • Forgetting to clear the ecommerce object before pushing new data
  • Missing required parameters like currency or transaction_id
  • Not enabling “Send E-commerce data” in the GA4 tag

Wrap-Up

You now have a working GA4 e-commerce tracking setup. The key steps were: push events to the data layer, create variables and triggers in GTM, configure the GA4 tag, and test thoroughly. Next, repeat this process for other e-commerce events like view_item and add_to_cart.

Julius
Written by

Julius

Web Analytics Consultant

I help businesses understand their data through proper analytics implementation. With years of experience in Google Analytics, Tag Manager, and tracking solutions, I write practical guides that focus on real-world implementation.

Need Help With Your Analytics Setup?

Whether you are implementing GA4, setting up consent management, or building custom tracking solutions, I can help you get it right the first time.