Lesson 6 of 7
The Ecommerce DataLayer
GA4 ecommerce is entirely dataLayer-driven. A small set of standard events describes the shopping journey, each carrying an items array with a consistent shape.
1view_item→2add_to_cart→3begin_checkout→4purchase
dataLayer.push({ ecommerce: null }); // clear the previous object
dataLayer.push({
event: "purchase",
ecommerce: {
transaction_id: "T-1042",
value: 49.0,
currency: "USD",
items: [
{ item_id: "SKU_1", item_name: "Cap", price: 49.0, quantity: 1 }
]
}
});Two habits matter: clear the ecommerce object before each push so values do not leak between events, and keep the item fields (item_id, item_name, price, quantity) identical across every event.
Key takeaway
Use the standard GA4 ecommerce events and item shape, and always clear ecommerce before a new push.