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:
- What e-commerce events GA4 expects
- How to structure your data layer
- How to configure tags and triggers in GTM
- 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.
- Go to GTM → Variables → New
- Choose Data Layer Variable
- Set the variable name to
ecommerce.items - 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.
- Go to GTM → Triggers → New
- Choose Custom Event
- Enter
purchaseas the event name - Save the trigger
Step 5: Create the GA4 Event Tag
Finally, create a tag that sends the event to GA4.
- Go to GTM → Tags → New
- Choose GA4 Event
- Select your GA4 Configuration tag
- Set the event name to
purchase - Under E-commerce, check “Send E-commerce data”
- Set Data source to “Data Layer”
- Attach your purchase trigger
- 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.
- GTM Preview mode: Click Preview in GTM, then trigger a test purchase on your site. Confirm the tag fires.
- GA4 DebugView: Go to GA4 → Admin → DebugView. You should see the purchase event with all parameters.
- 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
- 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.
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.