All guides
GA420 min· Beginner

Build a GA4 purchase event from scratch

From a blank GTM container to a verified GA4 purchase event with full ecommerce items — dataLayer push, variables, trigger, GA4 Event tag, DebugView verification.

Before you start — you'll need
  • GA4 property created with a Web Data Stream
  • GTM container installed on your site
  • Ability to push to the dataLayer on the thank-you page
By the end you'll have
  • purchase event in GA4 Realtime + DebugView
  • Revenue + items populated in Monetisation → Ecommerce purchases
  • Marked as a Key event so Google Ads can import it
Step 1

Wire the GA4 Google Tag

GTM → Tags → New → Google Tag. Paste your G-XXXXXXXXXX. Trigger: Initialization — All Pages. Save.

That single tag gives you automatic page_view + session_start + first_visit. You don't need a separate config tag.

Step 2

Push the purchase event from your thank-you page

On the order confirmation page, push the GA4-spec purchase event into the dataLayer. The shape matters — Google reads exact key names.

<script>
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({ ecommerce: null });
  window.dataLayer.push({
    event: "purchase",
    ecommerce: {
      transaction_id: "ORD-12345",
      value: 89.50,
      currency: "GBP",
      tax: 14.92,
      shipping: 4.99,
      coupon: "SUMMER10",
      items: [
        {
          item_id: "SKU_001",
          item_name: "Resistance Bands",
          item_brand: "Trevill",
          item_category: "Fitness",
          price: 29.00,
          quantity: 1
        }
      ]
    }
  });
</script>
Tip: Push after the page is rendered, not inside <head> — GTM needs to be loaded.
Step 3

Create the trigger + variables

Trigger: Custom Event, event name purchase. Variables: nothing extra needed — the GA4 Event tag reads the ecommerce object straight from the dataLayer.

Step 4

Create the GA4 Event tag

Tags → New → Google Analytics: GA4 Event. Measurement ID: your G-XXXXXXXXXX. Event Name: purchase. Open More Settings → Ecommerce and tick Send Ecommerce data, Data Source: Data Layer. Trigger: CE – purchase.

Tip: If you forget the Ecommerce tick, GA4 sees the event but the items array is dropped.
Step 5

Verify in DebugView

GA4 → Admin → DebugView. In another tab, hit Preview in GTM and complete a test purchase. Within 30s you should see purchase in the DebugView stream with value, currency, items populated. Click the event → Items tab — check each item_id and price.

Step 6

Mark as Key event + verify reports

GA4 → Admin → Events. Find purchase and toggle Mark as key event. It now shows in Monetisation → Ecommerce purchases (24h delay), and can be imported into Google Ads as a conversion.

Common pitfalls
  • Pushing the event before GTM loads — wrap in DOMContentLoaded if you're not sure.
  • Sending transaction_id as a number not a string — fine, but be consistent or you'll get duplicate counts.
  • Not setting Data Layer Version 2 on items DLV — items array reads as undefined.
  • Including PII (email, name) inside the items array — Google may flag the property.
  • Currency code in lowercase — must be ISO 4217 uppercase (GBP, USD, EUR).
Official references
Keep going