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, andpurchasebefore 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
| Event | When to Fire | Purpose |
|---|---|---|
view_item | User views a product page | Product interest tracking |
add_to_cart | User adds item to cart | Cart behavior analysis |
begin_checkout | User starts checkout | Funnel analysis |
purchase | Transaction completes | Revenue and conversion tracking |
Recommended Events
| Event | When to Fire | Purpose |
|---|---|---|
view_item_list | User views category/collection page | Product discovery patterns |
select_item | User clicks a product from a list | Click-through from lists |
remove_from_cart | User removes item from cart | Cart abandonment analysis |
add_shipping_info | User enters shipping details | Checkout step tracking |
add_payment_info | User enters payment details | Checkout step tracking |
Optional Events
| Event | When to Fire | Purpose |
|---|---|---|
view_cart | User views cart page | Cart page engagement |
view_promotion | User sees a promotion banner | Promotion effectiveness |
select_promotion | User clicks a promotion | Promotion click-through |
refund | Transaction is refunded | Revenue 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:
| Parameter | Description |
|---|---|
item_brand | Product brand |
item_category | Primary category |
item_category2 | Sub-category |
item_category3 | Sub-sub-category |
item_variant | Size, color, etc. |
discount | Discount amount applied |
coupon | Coupon 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.
{ 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:
- Use Shopify’s built-in Google channel for basic setup
- For enhanced tracking, use a dedicated app like Elevar or Analyzify
- 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:
- Work with your development team to output data layer pushes on relevant pages
- Ensure product data is available server-side or via API
- Test thoroughly in staging before production
Testing and Debugging
Preview Mode Testing
- Enable GTM Preview mode
- Navigate through your site: product page → add to cart → checkout → purchase
- 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
- In GA4, go to Admin → DebugView
- Enable debugging in GTM (check “Enable debug mode” in your GA4 Config tag)
- 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:
| Scenario | What to Verify |
|---|---|
| Single product purchase | All item data correct, transaction_id unique |
| Multi-product purchase | All items included, value totals correctly |
| Product with variants | Variant data captured |
| Purchase with discount | Discount or coupon captured |
| Guest checkout | Events still fire without user login |
| Returning customer | No 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.
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
- GA4 e-commerce event reference — Google Analytics Help
- Recommended events for e-commerce — Google Analytics Help
- Google Tag Manager data layer documentation — Google Developers