Skip to content
🚀 Find us on Product Hunt

Google Analytics 4 Tracking Setup for WooCommerce

Quick answer: Use the free container builder wizard to select Google Analytics 4 and your events, enter your tracking ID, then import the generated file into Google Tag Manager - no manual tag setup needed for any of the 23 events below.

GA4 configuration and ecommerce event tracking via a native Google tag. This container uses a native GTM tag type for this platform.

Build my Google Analytics 4 container →

Events you can track

ecommerce events

engagement events

By Humayun Kabir Naim — Last updated: 6 November 2026

To track WooCommerce sales in GA4 through Google Tag Manager, you need three pieces working together: a plugin (or custom code) that pushes WooCommerce actions into the dataLayer, one GA4 event tag in GTM that reads that dataLayer, and a Custom Event trigger that fires it. You do not need a separate tag per event. Set the tag to send ecommerce data from the Data Layer and use {{Event}} as the event name, and GA4 receives view_item, add_to_cart, begin_checkout, purchase, and the rest in the format its Monetization reports expect. Below: the fast route with our free container, or the same setup built manually.

What gets tracked

If an event below is missing, the matching GA4 report stays empty — no setting inside GA4 can fill it in later.

EventWhen it fires in WooCommerce
view_item_listA shop, category, or related-products list is viewed
view_itemA single product page is viewed
select_itemA product is clicked from a list
add_to_cartAdd to Cart is clicked, including AJAX adds
remove_from_cartAn item is removed on the cart page
view_cartThe cart page is viewed
begin_checkoutThe checkout page is opened
add_shipping_infoA shipping method is chosen at checkout
add_payment_infoA payment method is chosen at checkout
purchaseThe thank-you page loads after payment
refundAn order is refunded in WooCommerce admin

Each event carries an items array with item_id, item_name, price, and quantity. Purchase also carries transaction_id, value, tax, shipping, and currency — those fields turn a plain event into revenue reporting.

Deep dives: Purchase, Add to Cart, Begin Checkout.

Before you start

  1. GTM installed on the store. One web container, in the header and immediately after the opening <body> tag. Check no theme setting or plugin has already added one — two containers cause duplicates.
  2. A dataLayer for WooCommerce. GTM cannot invent product data. Most stores use the free GTM4WP plugin: install it, paste your container ID in its settings, then under Settings → Integrations → WooCommerce enable enhanced ecommerce tracking. It then pushes the events above, with product data, as shoppers move through the store.
  3. A GA4 property and web data stream, and its Measurement ID (starts with G-).
  4. Admin access to GTM and GA4, to publish the container and check DebugView.

Set GA4 up first; the same dataLayer can then feed WooCommerce + Meta and WooCommerce + Google Ads. See all options on the WooCommerce hub.

GTM4WP WooCommerce settings with enhanced ecommerce tracking enabled

Route 1: Use the free TagManagerBuilder container

Open the GTM Container Builder, choose WooCommerce, then GA4, and tick the events you want. Enter your Measurement ID, download the JSON, then in GTM go to Admin → Import Container and choose Merge → Overwrite conflicting tags, triggers, and variables. Test with the testing section below before publishing. Import failed? See the GTM container import error guide.

Note: the container does not replace GTM4WP. The container reads the dataLayer; the plugin creates it. You need both.

Route 2: Build it manually in GTM

Step 1 — Base Google tag

Tags → New, choose the Google Tag type, enter your Measurement ID, and set the trigger to Initialization – All Pages. If your container already has a GA4 configuration or Google tag for the same ID, keep that one and skip this step — two base tags double your pageviews.

Google Tag in GTM with a GA4 Measurement ID on the Initialization trigger

Step 2 — The ecommerce event tag

Create a tag of type Google Analytics: GA4 Event:

Because the name comes from {{Event}}, this one tag forwards whatever was pushed — add_to_cart arrives as add_to_cart, purchase as purchase. That is why you do not need eleven tags.

GA4 event tag in GTM sending ecommerce data from the Data Layer

Step 3 — Custom Event trigger

Attach a trigger of type Custom Event, tick Use regex matching, and enter:

view_item_list|view_item|select_item|add_to_cart|remove_from_cart|view_cart|begin_checkout|add_shipping_info|add_payment_info|purchase|refund

Without this, the tag would also fire on clicks, scrolls, and other dataLayer events and send junk events to GA4.

Custom Event trigger matching GA4 ecommerce event names with regex

Step 4 — Variables for later use (recommended)

In Variables → New → Data Layer Variable (Data Layer Version 2), create ecommerce.transaction_id, ecommerce.value, ecommerce.currency, and ecommerce.items. GA4 reads the ecommerce object automatically, but Google Ads and Meta tags will reuse these variables later. Save — then test before publishing.

Data Layer Variables for transaction ID, value, currency, and items in GTM

What a correct purchase push looks like

Compare your thank-you page push against this, field by field:

dataLayer.push({ ecommerce: null }); // clear the previous object first
dataLayer.push({
  event: "purchase",
  ecommerce: {
    transaction_id: "1042",
    value: 129.99,
    tax: 10.00,
    shipping: 5.00,
    currency: "USD",
    items: [{
      item_id: "SKU-123",
      item_name: "Trail Running Shoes",
      item_category: "Footwear",
      price: 119.99,
      quantity: 1
    }]
  }
});

Two details catch people out: value, price, and quantity must be numbers, not text — "129.99" in quotes will not total correctly. And the clearing push matters: without it, items from an earlier add_to_cart can leak into the purchase and inflate the order.

Test it: GTM Preview and GA4 DebugView

  1. Click Preview in GTM and open your store in Tag Assistant.
  2. Shop like a customer: category, product, add to cart, cart, checkout, and a test order (use a test payment gateway or a full coupon).
  3. In the Preview timeline, click add_to_cart, begin_checkout, then purchase. Your GA4 tag should sit under Tags Fired each time.
  4. On the purchase event, open the Data Layer tab and confirm transaction_id, value, currency, and items show real order values, not undefined.
  5. In GA4, open Admin → DebugView, repeat one action, and confirm the event arrives with its parameters. DebugView is live; Monetization reports are not — judge the setup here.
  6. Only then click Submit in GTM to publish.
GTM Preview purchase event with the ecommerce object expanded GA4 ecommerce tag fired on the purchase event in GTM Preview Purchase event and parameters in GA4 DebugView

WooCommerce-specific troubleshooting

Purchase fires twice. Look for two senders, not two triggers: a WooCommerce analytics plugin, a theme setting, or a hardcoded gtag.js snippet may send purchase alongside GTM, or two tracking plugins may both push it. Search your page source for your Measurement ID — it should be sent through GTM only. Disable the other sender; do not “fix” it by deleting the GTM tag.

Tag Assistant showing one GTM container on the WooCommerce thank-you page

The same order counts again on refresh. Thank-you pages get reloaded, revisited from email links, and restored by browsers, and a page-load push fires every time. GA4 deduplicates on transaction_id in reporting, but raw events still repeat. Check whether your dataLayer plugin can guard the push to once per order, and judge duplication by unique transaction IDs in GA4, not by Preview.

Items show as (not set). The tag fired, but items was empty, or missing item_id and item_name, when it fired — usually the push happened before product data was ready, or the plugin's ecommerce feature is off. Check the array in Preview's Data Layer tab for that exact event.

Revenue is $0 or missing. Inspect value and currency on the purchase push. Missing currency, a formatted string such as "$129.99", or a zero-value test order all cause this. Fix the format in the dataLayer, not in GA4.

Checkout events missing, purchase works. begin_checkout, add_shipping_info, and add_payment_info depend on your checkout layout: block checkout, one-page checkout plugins, and AJAX shipping updates change when — or whether — these steps push. Test each step in Preview. If the push never happens, that is a plugin/dataLayer issue; no trigger can fire on an event that was never pushed.

Next steps once this is clean: Advanced server-side tracking, the full Server-Side Tracking for WooCommerce guide, and Consent Mode v2 with the Consent Mode Checker.

Frequently asked questions

Do I still need GTM4WP if I use the TagManagerBuilder container?

Yes. The container holds the tags, triggers, and variables that read the dataLayer; GTM4WP creates the WooCommerce dataLayer. Without a dataLayer source, the GA4 tag fires with no product or order data to send.

Should I create a separate GA4 tag for every event?

No. One GA4 event tag using {{Event}}, with Send Ecommerce Data set to Data Layer, handles all eleven events. Separate tags repeat the same job and make duplicates far more likely.

My tag fires in Preview but nothing appears in GA4 reports — why?

Check the Measurement ID matches your web stream, confirm the event appears in DebugView, then allow for delay: standard GA4 reports can take 24–48 hours. If it is in DebugView, the setup works and the report has not processed yet.

Can I track refunds in GA4?

Yes — a refund event with the original transaction_id and, for a partial refund, the refunded items and value. A full refund needs only the transaction ID. The push normally happens when the refund is processed in WooCommerce admin.

Does this work with the WooCommerce block checkout?

Core events — view, cart, purchase — generally do, if your dataLayer plugin supports the block checkout. The checkout-step events are fragile, because shipping and payment update in place. Test those three in Preview on your own store before relying on them.

Does Consent Mode change what GA4 receives?

Yes. Visitors who decline analytics consent send limited, cookieless pings instead of full hits, and some data is modelled. That is expected — but your banner must actually send consent signals to GTM, or every visitor will look like a refusal.

Share with