Sabuj Kundu 22nd Jul 2025

Introduction

Tracking ecommerce interactions like Add to Cart, Checkout, and Purchase events is critical for understanding user behavior and improving conversion rates. In this guide, we’ll show you how to implement these events using Google Tag Manager (GTM) and send them to Google Analytics 4 (GA4).

Prerequisites

  • Google Tag Manager installed on your site
  • Google Analytics 4 property connected
  • Basic dataLayer implementation (manual or via plugin)

Step 1: Configure GA4 in GTM

  1. Go to GTM → Tags → New.
  2. Select GA4 Configuration tag.
  3. Enter your Measurement ID (from GA4).
  4. Trigger on All Pages.
  5. Save the tag and publish.

Step 2: Push Ecommerce Events to dataLayer

Use JavaScript or plugin support to push ecommerce events.

Add to Cart Example:

dataLayer.push({
  event: "add_to_cart",
  ecommerce: {
    items: [{
      item_id: "P12345",
      item_name: "T-shirt",
      price: 29.99,
      quantity: 1
    }]
  }
});

Checkout Example:

dataLayer.push({
  event: "begin_checkout",
  ecommerce: {
    items: [...]
  }
});

Purchase Example:

dataLayer.push({
  event: "purchase",
  ecommerce: {
    transaction_id: "T12345",
    value: 59.99,
    currency: "USD",
    items: [...]
  }
});

Step 3: Create GA4 Event Tags in GTM

Add to Cart Tag:

  • Tag Type: GA4 Event
  • Event Name: add_to_cart
  • Event Parameter: items = {{DLV - ecommerce.items}}
  • Trigger: Custom Event → add_to_cart

Repeat the above steps for begin_checkout and purchase events.

Step 4: Create Data Layer Variables

  1. Go to Variables → New → Data Layer Variable.
  2. Name: ecommerce.items
  3. Repeat for: ecommerce.transaction_id, ecommerce.value, etc.

Step 5: Test with Preview Mode

  • Click Preview in GTM.
  • Enter your website URL.
  • Trigger Add to Cart, Checkout, and Purchase actions.
  • Confirm events are firing and sending to GA4.

Step 6: Verify in GA4

Go to Realtime or DebugView in Google Analytics 4 and check that events are showing properly.

Miscellaneous Information: Comfort Resume Builder – Best Resume Builder for WordPress

Create resume with all possible sections. Display in frontend. Export as json, pdf. Frontend resume creation dashboard.

Learn more about Comfort Resume

Conclusion

With GA4 and GTM, tracking ecommerce events like Add to Cart, Checkout, and Purchase becomes seamless. Implementing these correctly provides you with actionable insights that can boost conversions and revenue.