
Data Layers for GA4 Ecommerce Events Guide
When it comes to using Data Layers for Enhanced Ecommerce in Google Analytics 4 (GA4), we felt it needed a whole separate guide so we can really get into the details of it. This guide is going to talk about what Data Layers you will need to enable Enhanced Ecommerce, what each Data Layer does, and where to use them.
- What are Data Layers
- Why are Data Layers important for GA4?
- Understanding the items Array
- GA4 Ecommerce Parameter Reference
- The view_item_list Event
- The select_item Event
- The view_item Event
- The add_to_cart Event
- The remove_from_cart Event
- The view_promotion Event
- The select_promotion Event
- The begin_checkout Event
- The Checkout Option Events
- The purchase Event
- The refund Event
What are Data Layers?
A Data Layer is a JavaScript object used to pass information from your website into Google Tag Manager and then into GA4. This data is not visible to users but can be leveraged to track detailed ecommerce interactions.
Why are Data Layers important for GA4?
GA4 uses an event-based model, which means everything is tracked via events like view_item
, add_to_cart
, etc. These need to be passed correctly using a Data Layer structure that GA4 can interpret. Doing this properly enables accurate reporting and deep analysis through GA4 and BigQuery.
Understanding the items
Array
Every GA4 ecommerce event shares a common structure: the items
array. This array holds one or more product objects, and its structure remains consistent across events like view_item
, add_to_cart
, purchase
, and others. GA4 expects the same parameter names across all events for proper attribution and reporting.
Here’s what a consistent items
array might look like:
items: [{ item_id: 'SKU_12345', item_name: 'Sample Product', item_brand: 'BrandName', item_category: 'CategoryName', item_variant: 'Size or Color', price: 29.99, quantity: 1, currency: 'GBP' }]
Using the same structure ensures GA4 correctly joins up impressions, clicks, views, cart adds, and purchases into unified product journeys.
GA4 Ecommerce Parameter Reference
Parameter | Required? | Applies To | Description |
---|---|---|---|
item_id |
Yes | All ecommerce events | Unique product identifier (SKU or ID). Required for matching across events. |
item_name |
Yes | All ecommerce events | Name of the product. |
item_brand |
No | All | The brand of the item. |
item_category , item_category2 – item_category5 |
No | All | Hierarchical product categories from broadest to most specific. |
item_variant |
No | All | Product variation (e.g. color, size). |
price |
Yes (for monetised events) | add_to_cart , purchase , etc. |
Price of the item. |
quantity |
Yes (where applicable) | add_to_cart , purchase , refund |
Number of items affected by the action. |
coupon |
No | purchase , add_to_cart , view_item |
Discount code applied to the order or item. |
affiliation |
No | purchase |
Store or partner affiliation where the sale occurred. |
transaction_id |
Yes | purchase , refund |
Unique ID for the transaction. |
value |
Yes | purchase |
Revenue for the entire transaction |
shipping |
No | purchase |
Shipping cost. |
tax |
No | purchase |
Tax amount. |
currency |
Yes | All monetary events | Currency code in ISO 4217 format (e.g., GBP, USD, EUR). Required for revenue tracking. |
index |
No | view_item_list , select_item |
Position of the item in the list. |
item_list_name |
No | view_item_list , select_item |
The name of the list the item appeared in (e.g., “Homepage” or “Search Results”). |
item_list_id |
No | view_item_list , select_item |
A unique ID for the item list being displayed or interacted with. |
promotion_id |
No | view_promotion , select_promotion |
Identifier for an internal promotion banner. |
promotion_name |
No | view_promotion , select_promotion |
Name of the promotion. |
creative_name |
No | view_promotion , select_promotion |
Name of the creative or ad (e.g., “Banner 1”). |
creative_slot |
No | view_promotion , select_promotion |
Placement of the promotion on the page (e.g., “homepage_banner_top”). |
shipping_tier |
No | add_shipping_info |
User-selected shipping level (e.g., Free, Next Day). |
payment_type |
No | add_payment_info |
User-selected payment method (e.g., Visa, PayPal). |
Ensure consistency for parameters like item_id
, item_name
, and currency
across all ecommerce events. In GA4, consistency is key for attribution and funnel analysis.
The view_item_list Event
What is it? This event fires when a user sees a list of products (like a category or search results page). Each product shown should be listed in the data layer.
What does it do? It helps GA4 track product exposure in lists and surfaces list names, item positions, and CTR analysis via events.
Where does it go? Place this in the <head>
of any product listing page, or fire it dynamically as more products appear on scroll.
dataLayer.push({ event: 'view_item_list', ecommerce: { item_list_id: 'home_page', item_list_name: 'Homepage', items: [ { item_id: '345678', item_name: 'Product 1', price: 10.99, item_brand: 'Propellernet', item_category: 'Shorts', item_variant: 'Blue', index: 1 }, { item_id: '456789', item_name: 'Product 2', price: 45.99, item_brand: 'Propellernet', item_category: 'Trousers', item_variant: 'Red', index: 2 } ] } });
The select_item Event
What is it? Fired when a user clicks or selects a product from a product list.
What does it do? GA4 uses this to calculate CTR on lists, tracking how many impressions turn into clicks.
Where does it go? Fire this event when a user interacts with a product in a list to visit its detail page.
dataLayer.push({ event: 'select_item', ecommerce: { item_list_id: 'home_page', item_list_name: 'Homepage', items: [{ item_id: '345678', item_name: 'Product 1', price: 10.99, item_brand: 'Propellernet', item_category: 'Shorts', item_variant: 'Blue', index: 1 }] } });
The view_item Event
What is it? Sent when a user lands on a product detail page.
What does it do? This allows GA4 to track how often users are interested enough to view a product in full detail.
Where does it go? Add this to your product page, ideally in the <head>
, or trigger it on load.
dataLayer.push({ event: 'view_item', ecommerce: { items: [{ item_id: '345678', item_name: 'Product 1', price: 10.99, item_brand: 'Propellernet', item_category: 'Shorts', item_variant: 'Blue' }] } });
The add_to_cart Event
What is it? Triggers when a product is added to the cart.
What does it do? GA4 uses this to measure intent-to-buy behaviour. It helps track how many product views and clicks convert into adds-to-cart.
Where does it go? Fire this on any click or action that successfully adds an item to the cart.
dataLayer.push({ event: 'add_to_cart', ecommerce: { items: [{ item_id: '345678', item_name: 'Product 1', price: 10.99, item_brand: 'Propellernet', item_category: 'Shorts', item_variant: 'Blue', quantity: 1 }] } });
The remove_from_cart Event
What is it? Triggered when a user removes a product from their cart.
What does it do? It tracks friction or indecision in the buying process and can inform on product performance and UX problems.
Where does it go? Fire it wherever a remove-from-cart interaction takes place.
dataLayer.push({ event: 'remove_from_cart', ecommerce: { items: [{ item_id: '345678', item_name: 'Product 1', price: 10.99, item_brand: 'Propellernet', item_category: 'Shorts', item_variant: 'Blue', quantity: 1 }] } });
The view_promotion Event
What is it? Sent when a user views an internal site promotion like a homepage banner or featured section.
What does it do? Enables GA4 to track the reach of internal marketing placements.
Where does it go? On page load for pages with promo slots (e.g., homepage banners).
dataLayer.push({ event: 'view_promotion', ecommerce: { promotions: [{ promotion_id: 'GA-Train-Apr-25', promotion_name: 'GA4 Training April 2025', creative_name: 'Banner 1', creative_slot: 'Homepage Banner' }] } });
The select_promotion Event
What is it? Fired when a user clicks an internal promotion (e.g. a banner).
What does it do? Lets GA4 know which promotions are driving engagement.
Where does it go? Add this event to any interaction that links through from a promotion.
dataLayer.push({ event: 'select_promotion', ecommerce: { promotions: [{ promotion_id: 'GA-Train-Apr-25', promotion_name: 'GA4 Training April 2025', creative_name: 'Banner 1', creative_slot: 'Homepage Banner' }] } });
The begin_checkout Event
What is it? Marks the first step of the checkout process.
What does it do? Allows GA4 to track how many users start checkout versus drop off at earlier stages.
Where does it go? Place it on the first page or action that moves a user into checkout.
dataLayer.push({ event: 'begin_checkout', ecommerce: { items: [{ item_id: '345678', item_name: 'Product 1', price: 10.99, item_brand: 'Propellernet', item_category: 'Shorts', item_variant: 'Blue', quantity: 1 }] } });
Checkout Option Events
What are they? add_shipping_info
and add_payment_info
are sent when users choose a shipping tier or a payment method.
What do they do? Track options users select during checkout that affect delivery and payment preferences.
Where do they go? Fire add_shipping_info
when a shipping method is selected, and add_payment_info
when a payment method is chosen.
Shipping Info:
dataLayer.push({ event: 'add_shipping_info', ecommerce: { shipping_tier: 'Express', items: [{ item_id: '345678', item_name: 'Product 1', quantity: 1 }] } });
Payment Info:
dataLayer.push({ event: 'add_payment_info', ecommerce: { payment_type: 'Credit Card', items: [{ item_id: '345678', item_name: 'Product 1', quantity: 1 }] } });
The purchase event
What is it? Sent after a successful transaction.
What does it do? It finalises the ecommerce flow, sending total revenue, tax, coupon usage, shipping, and product details.
Where does it go? Fire this once, on the confirmation or order success page only.
dataLayer.push({ event: 'purchase', ecommerce: { transaction_id: 'T123', affiliation: 'Online Store', value: 22.99, tax: 4.60, shipping: 2.00, currency: 'GBP', coupon: 'SUMMER_SALE', items: [ { item_id: '345678', item_name: 'Product 1', price: 10.99, quantity: 1, item_brand: 'Propellernet', item_category: 'Shorts', item_variant: 'Blue' }, { item_id: '32145', item_name: 'Product 2', price: 5.00, quantity: 2, item_brand: 'Propellernet', item_category: 'Shirt', item_variant: 'Red' } ] } });
The refund Event
What is it? Sent when a transaction (or part of it) is refunded.
What does it do? Tracks loss of revenue and helps correct product revenue attribution.
Where does it go? Trigger this when an online refund is successfully issued. GA4 supports both full and partial refunds.
Full refund:
dataLayer.push({ event: 'refund', ecommerce: { transaction_id: 'T123' } });
Partial refund:
dataLayer.push({ event: 'refund', ecommerce: { transaction_id: 'T123', items: [ { item_id: '345678', quantity: 1 }, { item_id: '32145', quantity: 1 } ] } });
Need help implementing these Data Layers? Join our GA4 training or check out our Analytics services.