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.
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
| Event | When to fire |
|---|---|
view_item | Product page view |
add_to_cart | Add product to cart |
remove_from_cart | Remove product from cart |
view_cart | View cart page |
begin_checkout | Start checkout process |
add_payment_info | Enter payment details |
add_shipping_info | Enter shipping details |
purchase | Complete transaction |
Additional useful events
| Event | When to fire |
|---|---|
view_item_list | View product list/category page |
select_item | Click on product in a list |
view_promotion | See a promotion banner |
select_promotion | Click on promotion |
refund | Process 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:
| Field | Required? | Notes |
|---|---|---|
item_id | ✅ Yes | Unique product identifier (SKU) |
item_name | ✅ Yes | Product name |
price | ✅ Yes | Unit price |
quantity | ✅ Yes | Number of items |
item_brand | Recommended | Brand name |
item_category | Recommended | Primary category |
item_variant | Recommended | Size, color, etc. |
coupon | Optional | Applied coupon code |
discount | Optional | Discount 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:
- Create a Custom Event trigger matching the event name
- 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:
| Platform | Solution |
|---|---|
| Shopify | Built-in GA4 integration, or enhanced plugins |
| WooCommerce | MonsterInsights, GTM4WP, or similar |
| Magento | Google Analytics extension |
| BigCommerce | Built-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_idmust be unique. Duplicate IDs = double-counted revenue.
Verifying your setup
DebugView check
- Enable GA Debugger extension or use GTM Preview Mode
- Go to GA4 → Admin → DebugView
- Complete a test purchase
- Watch for
view_item,add_to_cart,begin_checkout,purchaseevents - Click each event to verify parameters are populated
Key things to verify
| Check | How |
|---|---|
| Events fire at right time | Walk through purchase flow in DebugView |
| Items array is populated | Click event, expand parameters, find items |
| Value and currency present | Check value and currency parameters |
| No duplicate transactions | Use unique transaction_id |
| Correct prices | Verify value matches actual cart total |
Monetization reports
After 24-48 hours:
- Go to Reports → Monetization
- Check E-commerce purchases report
- 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:
- Go to Admin → Events
- Find
purchase - 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_itemon product pages -
add_to_carton add-to-cart action -
begin_checkouton checkout start -
purchaseon order confirmation
Enhanced funnel (optional but valuable):
-
view_item_liston category pages -
select_itemon product clicks -
view_carton cart page -
remove_from_carton item removal -
add_shipping_infoon shipping step -
add_payment_infoon payment step
Configuration:
-
purchasemarked as key event - Tested in DebugView
- Verified in Monetization reports
What's next?
Once basic e-commerce tracking works:
- Set up Shopify-specific tracking if applicable
- Configure enhanced funnel analysis
- 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.