Complete Ecommerce Data Layer Setup for GA4 | Adslytics | Adslytics

GTM Data Layer How-To Guide

The Complete Ecommerce Data Layer Setup for GA4

By Muhammad Farooq · March 20, 2026 · 7 min read
The Complete Ecommerce Data Layer Setup for GA4

GA4 Ecommerce Data Layer Structure

GA4 enhanced ecommerce uses a specific data layer schema. Each ecommerce event wraps its data in an ecommerce object with an items array. Getting the field names exactly right is critical — wrong field names silently result in missing data in GA4 reports.

Item Object Structure (Required Fields)

{
  'item_id': 'SKU-001',         // Required: your product SKU or ID
  'item_name': 'Product Name',  // Required: product name
  'quantity': 1,                // Required for purchase/add_to_cart events
  'price': 29.99,               // Required for revenue events
  'currency': 'GBP',            // Currency (alternatively set at ecommerce level)
  // Optional but recommended:
  'item_brand': 'Brand Name',
  'item_category': 'Category',
  'item_variant': 'Blue / Large',
  'item_list_name': 'Search Results',  // For list tracking
  'index': 1                    // Position in list (1-based)
}

view_item_list (Category Page / Search Results)

window.dataLayer.push({ecommerce: null});
window.dataLayer.push({
  'event': 'view_item_list',
  'ecommerce': {
    'item_list_id': 'category_mens_shoes',
    'item_list_name': "Men's Shoes",
    'items': [
      {'item_id': 'SKU-001', 'item_name': 'Product A', 'price': 59.99, 'index': 1, 'quantity': 1},
      {'item_id': 'SKU-002', 'item_name': 'Product B', 'price': 49.99, 'index': 2, 'quantity': 1}
    ]
  }
});

view_item (Product Detail Page)

window.dataLayer.push({ecommerce: null});
window.dataLayer.push({
  'event': 'view_item',
  'ecommerce': {
    'currency': 'GBP',
    'value': 59.99,
    'items': [
      {'item_id': 'SKU-001', 'item_name': 'Product A', 'price': 59.99, 'item_category': 'Shoes', 'quantity': 1}
    ]
  }
});

add_to_cart

window.dataLayer.push({ecommerce: null});
window.dataLayer.push({
  'event': 'add_to_cart',
  'ecommerce': {
    'currency': 'GBP',
    'value': 59.99,
    'items': [
      {'item_id': 'SKU-001', 'item_name': 'Product A', 'price': 59.99, 'quantity': 1}
    ]
  }
});

begin_checkout

window.dataLayer.push({ecommerce: null});
window.dataLayer.push({
  'event': 'begin_checkout',
  'ecommerce': {
    'currency': 'GBP',
    'value': 119.98,  // Cart total
    'coupon': 'SUMMER10',  // If applied
    'items': [ /* all cart items */ ]
  }
});

purchase (Most Important — Use on Order Confirmation)

window.dataLayer.push({ecommerce: null});
window.dataLayer.push({
  'event': 'purchase',
  'ecommerce': {
    'transaction_id': 'T12345',   // Unique order ID — required, used for deduplication
    'value': 119.98,              // Revenue (total paid by customer)
    'tax': 19.99,
    'shipping': 5.99,
    'currency': 'GBP',
    'coupon': 'SUMMER10',         // Coupon code if used
    'items': [
      {'item_id': 'SKU-001', 'item_name': 'Product A', 'price': 59.99, 'quantity': 2}
    ]
  }
});

GTM Configuration

In GTM, configure the GA4 Event tag:

  • Event Name: set to {{Event}} (reads the 'event' field from the data layer push)
  • Ecommerce: enable "Send Ecommerce data" → Data Layer
  • Trigger: Custom Event trigger for each event name (purchase, add_to_cart, etc.)

Summary

GA4 ecommerce data layer requires precise field names — item_id (not id), item_name (not name), transaction_id (not transactionId). Always push ecommerce: null before each ecommerce event. The purchase event is the most critical — use the order ID as transaction_id for deduplication. Configure one GA4 Event tag in GTM with "Send Ecommerce data from Data Layer" enabled, triggered by all ecommerce event names.

See our Enhanced Ecommerce Tracking Setup service for complete implementation.

Need ecommerce data layer set up? Contact Adslytics.

Need expert tracking setup?

Our Google Tag Manager experts have delivered 500+ tracking setups with a 98% success rate.

Get a Free Consultation →
← Back to Blog
Muhammad Farooq

Author

Muhammad Farooq GTM & Analytics Expert · Adslytics Founder

Tracking specialist with 10+ years of experience in Google Tag Manager, GA4, Server-Side Tracking, and Google Ads. Founder of Adslytics — a dedicated analytics agency with a 98% success rate across 232+ projects on Upwork.

Top Rated Plus LinkedIn Visit the author's profile →