Don't have one? Create one ↗
← All courses

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

  1. Know what the page pushes

    Placing the order runs dataLayer.push({ event: "purchase", ecommerce: { value, items, transaction_id } }). GTM sees an event named purchase with the order details nested under ecommerce.
  2. Create the Custom Event trigger

    Triggers → New → Custom Event, event name purchase. It must match the pushed string exactly.
  3. Fire a GA4 purchase tag on it

    Build a GA4 Event tag named purchase that reads the ecommerce object (map value and the items array, plus transaction_id), and set the trigger above as its firing trigger. The course's Custom HTML - Test stand-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.

  1. In your GTM, click Preview.
  2. Paste the live URL above and click Connect.
  3. Interact with the live page and watch your tag fire in Tag Assistant.

What you should expect to see

Walk the shop to the end. In Tag Assistant a 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

0 of 16 lessons complete