Lesson 9 of 16
Track An Ecommerce Purchase
① Connect your GTM container
Paste your container ID to load it into this page. It only ever runs here.
Advanced: use a specific environment
Ecommerce tracking is the same pattern you already know, a dataLayer push picked up by a Custom Event trigger, but the push carries a structured ecommerce object: the order's value and an items array. GA4's recommended events have reserved names, and purchase is the one that books revenue.
This shop walks the full journey, view_item, add_to_cart, begin_checkout and finally purchase. Your job is the trigger and tag for that last step, so a GA4 purchase lands with a real value and at least one item.
Goal
Fire a GA4 purchase tag on the purchase event, carrying the ecommerce value and items.
Build it in GTM
Know what the page pushes
Placing the order runsdataLayer.push({ event: "purchase", ecommerce: { value, items, transaction_id } }). GTM sees an event namedpurchasewith the order details nested underecommerce.Create the Custom Event trigger
Triggers → New → Custom Event, event namepurchase. It must match the pushed string exactly.Fire a GA4 purchase tag on it
Build a GA4 Event tag namedpurchasethat reads theecommerceobject (mapvalueand theitemsarray, plustransaction_id), and set the trigger above as its firing trigger. The course'sCustom HTML - Teststand-in with<script></script>is an accepted placeholder.
Debug in Tag Assistant
Copy this lesson's live URL and paste it into GTM Preview, that is the page Tag Assistant connects to. It has the clickable elements, so this page stays clean for reading.
- In your GTM, click Preview.
- Paste the live URL above and click Connect.
- Interact with the live page and watch your tag fire in Tag Assistant.
What you should expect to see
purchase event appears in the left rail, and your GA4 purchase tag shows under Tags Fired with the value and items populated.Verify your container
Built it? Export your container, Admin → Export Container, choose your workspace, then drop the JSON here to check it against this lesson.
Drop your container .json here
or browse · checked in your browser, nothing is uploaded