Skip to content
Performetic

Conversion Optimization

How to set up GA4 ecommerce tracking

Written by Published Last updated 5 min read
How to set up GA4 ecommerce tracking

In short

You set up GA4 ecommerce tracking by sending Google's recommended events, such as view_item, add_to_cart, begin_checkout and purchase, with an items array. Your site pushes events to the dataLayer, Google Tag Manager forwards them to GA4, you validate them in DebugView, and you configure consent mode to respect user choices.

Contents
  1. How do you set up GA4 ecommerce tracking?
  2. Which ecommerce events does GA4 use?
  3. Why does the items array matter so much?
  4. How do you send events with the dataLayer?
  5. How do you configure GA4 in Google Tag Manager?
  6. How do you validate the setup with DebugView?
  7. How do you configure consent mode?
  8. What are the most common GA4 ecommerce mistakes?
  9. Key takeaways

How do you set up GA4 ecommerce tracking?

You set up GA4 ecommerce tracking by sending Google's recommended ecommerce events with the right parameters. At each key step (product view, add to cart, checkout start, purchase) your site pushes an event to the dataLayer, and Google Tag Manager forwards it to GA4. After setup, you validate events in DebugView and configure consent mode according to user choices.

Accurate ecommerce tracking underpins funnel analysis, product performance, campaign evaluation and the conversion signals sent to ad platforms. Missing or broken tracking means every decision rests on bad data. That is why validating measurement is the first job before any conversion optimization work.

Which ecommerce events does GA4 use?

The GA4 ecommerce documentation on Google for Developers defines recommended event names for each step of the shopping journey. Using those names unchanged means GA4's built in ecommerce reports fill automatically.

Event When to send it Key parameters
view_item_list A category or search results list is viewed item_list_id, item_list_name, items
select_item A product is clicked in a list item_list_name, items
view_item A product page is viewed currency, value, items
add_to_cart A product is added to the cart currency, value, items
remove_from_cart A product is removed from the cart currency, value, items
view_cart The cart page is viewed currency, value, items
begin_checkout Checkout starts currency, value, coupon, items
add_shipping_info Shipping details are submitted currency, value, shipping_tier, items
add_payment_info Payment details are submitted currency, value, payment_type, items
purchase An order is completed transaction_id, currency, value, tax, shipping, items
refund An order is refunded transaction_id, currency, value, items

Why does the items array matter so much?

The items array is the heart of every ecommerce event. Each item needs at least an item_id or item_name, while fields such as price, quantity, item_brand, item_category and item_variant enrich product and category reports. Use the same item_id for a product across all events, or you lose the ability to follow it through the funnel.

How do you send events with the dataLayer?

With Google Tag Manager, your site pushes ecommerce data to the dataLayer. Google's GTM examples clear the previous ecommerce object before each new ecommerce event so data from one event does not leak into the next.

Here is an example purchase event:

window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ ecommerce: null });
window.dataLayer.push({
  event: "purchase",
  ecommerce: {
    transaction_id: "ORD-104582",
    value: 89.90,
    tax: 14.98,
    shipping: 0,
    currency: "EUR",
    coupon: "SUMMER10",
    items: [
      {
        item_id: "SKU-2231",
        item_name: "Linen Duvet Cover Set",
        item_brand: "Example Brand",
        item_category: "Home Textiles",
        item_variant: "Double / Beige",
        price: 89.90,
        quantity: 1
      }
    ]
  }
});

Points to watch:

  • value should be consistent with the sum of price x quantity in items. Decide once whether tax and shipping are included and apply the same logic everywhere.
  • currency must be sent with every event that has a value, or revenue reports break.
  • transaction_id must be unique per order. It helps prevent the same order being counted twice when the confirmation page reloads.
  • Send numbers as numbers, not as quoted strings.

How do you configure GA4 in Google Tag Manager?

  1. Create a Google tag with your GA4 measurement ID and fire it on all pages.
  2. Create a Custom Event trigger for each ecommerce event (for example, event name purchase).
  3. Create a GA4 Event tag, set the event name to match the trigger and enable sending ecommerce data from the dataLayer.
  4. To handle several events with one tag, use a regex trigger listing the event names and the built in Event variable as the event name.
  5. Never publish changes without testing them in preview mode.

Platforms such as Shopify and WooCommerce offer built in integrations that can send ecommerce events automatically. Running a built in integration and a GTM setup at the same time is the most common cause of double counting, so choose one.

How do you validate the setup with DebugView?

DebugView, found in the GA4 admin area, shows events from devices in debug mode in real time. When GTM preview mode is on, your browser sends data in debug mode automatically.

During validation:

  1. Walk through a real journey from a product list to a product page, then the cart and checkout.
  2. Check that each expected event appears at each step and fires only once.
  3. Click into events to confirm currency, value and items are populated correctly.
  4. Place a test order and confirm purchase arrives with a transaction_id.
  5. A few days later, compare GA4 purchases with the order count in your store admin.

A small gap is normal, because ad blockers and declined consent stop some orders reaching GA4. A large gap, or GA4 showing more orders than the store, means something is wrong.

Google's consent mode adjusts how Google tags behave based on the user's cookie choice. The documentation defines four core consent types: ad_storage, ad_user_data, ad_personalization and analytics_storage. The basic logic:

  1. On page load, set a default consent state (usually denied) before any Google tags fire.
  2. Update the consent state when the user makes a choice in the cookie banner.
  3. Use your consent management platform's GTM integration for consent mode.

Google offers consent mode in two implementations, basic and advanced. In basic mode, tags do not load until consent is given; in advanced mode, tags load and send cookieless pings when consent is denied. Decide which fits you together with legal counsel, based on GDPR and the rules in your target markets.

Server side tracking can also reduce the losses of browser based measurement, which we cover in our server side tracking guide.

What are the most common GA4 ecommerce mistakes?

  • purchase firing again every time the confirmation page is reloaded
  • Missing currency parameters
  • item_id sent in different formats, such as SKU on product pages and product ID in the cart
  • A built in platform integration and GTM running side by side
  • Losing source attribution after redirects to a payment provider (add the payment domain to the unwanted referrals list)
  • Test orders mixing into live data

If you would like to audit your GA4 setup together, you can book a free growth analysis with the Performetic team through our contact page.

Key takeaways

  • Use Google's recommended event names unchanged so reports fill automatically.
  • Send currency, value and an items array with consistent item_id values in every event.
  • Clear the ecommerce object before each new ecommerce push in GTM.
  • Validate step by step in DebugView and compare GA4 purchases with store orders.
  • Configure consent mode with a default state and update logic that meets legal requirements.

Frequently asked questions

Which events are required for GA4 ecommerce?

There is no strictly required list, but for funnel analysis you should send at least view_item, add_to_cart, begin_checkout and purchase. For deeper analysis, add view_item_list, view_cart, add_shipping_info, add_payment_info and refund as well.

Why do GA4 purchases differ from my store orders?

Ad blockers, declined cookie consent and browser restrictions mean not every order reaches GA4, so a small gap is normal. If GA4 shows more orders than your store, the purchase event is probably firing twice; check confirmation page reloads and duplicate integrations.

Why are events not showing in DebugView?

DebugView only shows events from devices in debug mode. Make sure GTM preview mode is active, your ad blocker is off and analytics_storage consent is granted in your cookie banner. Also confirm you are looking at the correct GA4 property.

How does consent mode affect GA4 data?

Consent mode changes how Google tags behave when users decline cookies. In the basic implementation no data is sent without consent; in the advanced implementation cookieless pings are sent. Either way, some data from users who decline will be missing or modeled in your reports.

Sources

  1. Google for Developers: Measure ecommerce (GA4)
  2. Google for Developers: Recommended events (GA4)
  3. Google for Developers: Set up a purchase event
  4. Google for Developers: The data layer
  5. Google for Developers: Consent mode overview

Your ad budget deserves more.

We review your store and ad accounts and send you three concrete growth opportunities, free of charge.

Get a free audit
Get a free audit