Skip to content
10% off any project with promo code10% off with code

Google Analytics 4: Setting Up eCommerce Tracking

Contents
  1. The steps
  2. Data layer events
  3. view_item (product view)
  4. purchase
  5. GTM configuration
Published
Reading time
~1 min
Views
122
Reader rating
10 reviews
Author
Yevhen Fostenko
Senior Backend & DevOps Engineer
Google Analytics 4: Setting Up eCommerce Tracking Article
Need help with your website?
Describe the task on Telegram — I will assess it and suggest where to start. Reply within a day.
Message on Telegram
Free consultation and estimate. I reply quickly.

GA4 eCommerce gives you the full sales funnel. Here is how to set it up through Google Tag Manager.

The steps

  1. Create a GA4 property in Google Analytics
  2. Create a GTM container and install it on the site
  3. Push the data layer for each event
  4. Build the GTM tags, triggers and variables
  5. Verify in GA4 DebugView

Data layer events

view_item (product view)

dataLayer.push({
  event: 'view_item',
  ecommerce: {
    currency: 'UAH',
    value: 1500,
    items: [{
      item_id: 'SKU-001',
      item_name: 'Product name',
      price: 1500,
      quantity: 1
    }]
  }
});

purchase

dataLayer.push({
  event: 'purchase',
  ecommerce: {
    transaction_id: 'ORDER-123',
    value: 1500,
    currency: 'UAH',
    items: [{ item_id: 'SKU-001', price: 1500, quantity: 1 }]
  }
});

GTM configuration

Tag: GA4 Event → Event Name: {{DLV - event}} → the ecommerce parameters.
Trigger: Custom Event → event name matches RegEx: view_item|add_to_cart|purchase

Want this set up? GA4 for OpenCart or GA4 for WordPress.

Tags: google analytics 4ga4ecommercegtmtracking
Need help with your website?
Describe the task on Telegram — I will assess it and suggest where to start. Reply within a day.
Message on Telegram
Free consultation and estimate. I reply quickly.

Reader reviews

4.0
Write a review