Skip to content
🚀 Find us on Product Hunt

GTM Tracking Setup for WooCommerce

Configure GA4, Google Ads, Meta, TikTok and more for WooCommerce and generate a ready-to-import Google Tag Manager container.

Quick answer

To track a WooCommerce store with Google Tag Manager, you need three things working together: a dataLayer that describes what shoppers do (view a product, add to cart, check out, buy), a GTM container with a Google tag plus one GA4 event tag per ecommerce event, and a test order that proves a purchase event with transaction_id, value, currency and an items array lands in GA4. The recipes on this page generate the container part for you — tags, triggers and variables for GA4, Google Ads, Meta and the other tools — so you import it instead of building every tag by hand. The dataLayer itself usually comes from the free GTM4WP plugin, which outputs WooCommerce events in GA4 format.

How WooCommerce tracking works with Google Tag Manager

Google Tag Manager does not track anything on its own. It is a delivery system: it loads tags (GA4, Google Ads, Meta Pixel and the rest) and decides when each one fires, based on triggers that listen to the dataLayer. The dataLayer is a small JavaScript object on the page that describes what just happened — which product was viewed, what was added to the cart, what the order was worth.

On a WooCommerce store that chain has four links, and a break in any one of them means missing or wrong data:

  1. The store pushes events to the dataLayer. The usual route is the GTM4WP plugin (Google Tag Manager for WordPress), which outputs GA4-style ecommerce events for product, cart, checkout and order pages, including AJAX add to cart. The alternative is custom code on WooCommerce hooks in a child theme or a small plugin.
  2. GTM listens with triggers. A custom event trigger fires when the dataLayer event name matches — view_item, add_to_cart, begin_checkout, purchase and the rest.
  3. Tags send the data on. A Google tag loads the GA4 library on every page; a GA4 event tag fires per ecommerce event and reads the product and transaction data from dataLayer variables.
  4. The destination receives it. GA4 DebugView and its Monetisation reports, Google Ads conversions, Meta Events Manager — each one confirms the same events from its own side.

If you only see page views in GA4 and no revenue, the first link is usually the broken one: the dataLayer has no ecommerce events at all. Check with GTM Preview mode on a product page — if no view_item event appears in the left-hand event list, nothing downstream can work.

Build your WooCommerce container with TagManagerBuilder

Building the container by hand means creating a Google tag, a GA4 event tag for every ecommerce event, dataLayer variables for transaction_id, value, currency and items, custom event triggers for each event name, plus the equivalent tags for Google Ads and Meta. It is repetitive work and one mistyped variable name silently breaks an event.

The builder on this site generates that container for you:

  1. Choose WooCommerce as the platform and pick the tools you actually use — GA4 at minimum, then Google Ads and Meta if you run ads.
  2. Pick the events you want to track. Start with the full ecommerce set: view_item, view_item_list, add_to_cart, begin_checkout and purchase. Add page_view and form_submission if you want content and lead tracking in the same container.
  3. Enter your real IDs — your GA4 Measurement ID, Google Ads conversion ID and label, Meta Pixel ID. The builder uses the IDs you type, not placeholders, so the container it generates is ready to import.
  4. Download the container JSON and import it into GTM (Admin → Import Container). Choose Merge and rename on conflict if the container already has tags; choose Overwrite only on a fresh, empty container.
  5. Publish, then test with a real order — never trust an import until a test purchase appears in GA4 DebugView with the right value and transaction ID.

The recipe links below the builder take you to the same setup broken down per tool and event, so you can check exactly what each generated tag does before you import it.

TagManagerBuilder step 1: WooCommerce selected as the website platform
Step 1 of the builder: WooCommerce selected as the website platform.
TagManagerBuilder step 2: Google Analytics 4, Google Ads and Meta Pixel selected as tracking platforms for WooCommerce
Step 2: Google Analytics 4, Google Ads and Meta Pixel selected as the tracking platforms.
TagManagerBuilder step 3: Page View, View Item, View Item List, Add to Cart, Begin Checkout, Purchase and Form Submission events selected
Step 3: the seven WooCommerce events selected — Page View, View Item, View Item List, Add to Cart, Begin Checkout, Purchase and Form Submission.
TagManagerBuilder step 4: sample tracking IDs entered — GA4 Measurement ID, Google Ads Conversion ID and label, Meta Pixel ID
Step 4: sample tracking IDs entered (GA4 Measurement ID, Google Ads Conversion ID and label, Meta Pixel ID).
TagManagerBuilder step 5: Advanced Options with Consent Mode v2, Enhanced Conversions, Debug Mode, Cross-Domain Tracking and server-side tracking
Step 5: Advanced Options — Consent Mode v2, Enhanced Conversions, Debug Mode, Cross-Domain Tracking and server-side tracking are optional extras.
TagManagerBuilder step 6: WooCommerce GTM container generated successfully with 15 tags, 7 triggers and 6 variables, with Download JSON button
Step 6: the WooCommerce container generated — 15 tags, 7 triggers and 6 variables, ready to download as JSON.

Which WooCommerce events matter — and why

Not every event deserves the same attention. These are the ones that drive reporting and ad optimisation, in the order a shopper meets them:

EventFires whenWhat it tells youKey data
page_viewAny page loadsTraffic, landing pages, content performancepage location, page title
view_item_listA category or shop archive loadsWhich lists get seen (category, search results, related products)item list id, items
view_itemA product page is viewedProduct interest before any cart actionitem_id, item_name, price, category
add_to_cartA product is added, including AJAX add to cartReal buying intent; the top of your funnelitems, quantity, value
begin_checkoutCheckout startsWhere checkout drop-off beginsitems, value, coupon
purchaseOrder received (thank-you) page, onceRevenue, conversion rate, return on ad spendtransaction_id, value, tax, shipping, currency, items
form_submissionA form is sent (contact, newsletter, quote)Leads that never reach checkoutform id, form name

Two events do most of the commercial work. add_to_cart shows intent you can retarget — someone who added a product but never checked out is the highest-value audience most stores have. purchase is the only event that proves money changed hands, and it feeds GA4 revenue reports, Google Ads conversion value and Meta purchase optimisation. If you track nothing else, track those two properly, with value and currency on every hit.

view_item_list is the one most stores skip and later regret. Without it you cannot tell whether a category page is failing because nobody sees the products or because nobody clicks them — the difference decides whether you fix merchandising or pricing.

The dataLayer: what GTM actually reads

Every event above arrives as a dataLayer.push(). This is what a purchase push looks like on the order-received page — the shape the generated container expects:

dataLayer.push({
  event: 'purchase',
  ecommerce: {
    transaction_id: 'WC-4821',
    value: 89.97,
    tax: 14.99,
    shipping: 4.95,
    currency: 'GBP',
    items: [
      {
        item_id: 'SKU-114',
        item_name: 'Leather Weekend Bag',
        price: 84.99,
        quantity: 1
      }
    ]
  }
});

An add_to_cart push follows the same pattern, with the event name changed and the cart contents in items. The critical rules are the same for every event: the event name must match the trigger exactly (purchase, not Purchase or order_complete), value must be a number rather than a formatted string, and items must be an array of objects with item_id and price.

GTM4WP produces these pushes for you once you enable its WooCommerce integration and the GA4 events you need. If you build the dataLayer yourself with WooCommerce hooks, the purchase push needs one extra safeguard: store a flag in the order meta after the first push, and only push again if the flag is absent. That is what stops the thank-you page sending a second purchase every time a customer refreshes it.

Importing the container into GTM

  1. In GTM, open Admin → Import Container and choose the JSON file you downloaded.
  2. Pick the workspace the store uses. If you already have tags in that workspace, choose Merge and Rename conflicting tags, triggers, and variables — overwriting deletes whatever is already there.
  3. Open Tags and check the Google tag carries your GA4 Measurement ID, then open Variables and confirm the dataLayer variables point at ecommerce.transaction_id, ecommerce.value, ecommerce.currency and ecommerce.items.
  4. Click Preview, load the store, and walk through view → add to cart → checkout → test purchase. Each event should appear in Preview and fire its GA4 event tag.
  5. Only then click Submit → Publish. Publishing an untested container is how duplicate or missing purchase events reach production.

One container per store, and load it exactly once. If GTM is already inserted manually in the theme or through another plugin, set GTM4WP's container code to Off so the plugin feeds the dataLayer without inserting a second copy of the container. A doubled container doubles every event and page view in GA4.

Here is what an imported container looks like inside Google Tag Manager, from our own live container:

Google Tag Manager tags list in the Tag Manager Builder container GTM-5NF3RF2P showing the GA4 Configuration tag and GA4 event tags for view_item, add_to_wishlist, begin_checkout, form_submission and Calendly booking
After import, the Tags list looks like this — our own live Tag Manager Builder container (GTM-5NF3RF2P) with the GA4 Configuration tag and GA4 event tags for view_item, begin_checkout, add_to_wishlist and more.
GA4 Configuration tag in Google Tag Manager - a Google Tag using the GA4 Measurement ID variable, firing on All Pages before the GA4 event tags
The GA4 Configuration tag after import: a Google Tag that takes the Measurement ID from a variable, fires on All Pages, and is set to fire before every GA4 event tag.

Sending the same events to Google Ads and Meta

The same purchase event should feed every ad platform you use — that is the point of routing it through GTM rather than installing each platform's code separately.

Google Ads: add a Google Ads Conversion Tracking tag on the purchase trigger, with value, transaction ID and currency. Add the Conversion Linker tag on All Pages so clicks are attributed. If you collect customer email and phone at checkout, enable Enhanced Conversions so Google can match conversions that cookies miss. The transaction ID is what lets Google deduplicate — the same ID arriving twice counts once.

Meta: add the Meta Pixel base code through GTM and a Purchase event on the same purchase trigger, passing value and currency. Check it in Meta Events Manager with Test Events. If you later add server-side tracking, send the same eventID from browser and server so Meta deduplicates the pair instead of counting two purchases.

TikTok, Pinterest, LinkedIn and the others follow the same pattern in the generated container: one event tag per platform on the same trigger, reading the same dataLayer variables. Adding a platform later means adding its tag, not rebuilding the dataLayer.

Common WooCommerce GTM errors — and how to fix them

ProblemWhat you seeUsual causeFix
Container loads twicePage views and events doubled in GA4GTM inserted by both the theme and a pluginLoad GTM once; set GTM4WP container code to Off if the snippet is already in the theme
Purchase counted twiceTwo purchase events per order in GA4Thank-you page reloaded, or browser + server both sendingOrder-meta flag on the dataLayer push; matching eventID for browser/server pairs
Purchase missing entirelyCheckout works but no purchase in DebugViewPayment gateway redirects the customer away and backAdd gateway domains (PayPal, Stripe) to GA4's unwanted referrals list; confirm the thank-you page fires the push
add_to_cart never firesProducts added but no eventTheme uses AJAX add to cart and the plugin setting is offEnable AJAX add-to-cart tracking in GTM4WP, or push the event from the added_to_cart JavaScript event
No value on eventsEvents arrive with no revenueVariable points at the wrong dataLayer pathVariable must read ecommerce.value (a number), and the tag must pass it as the event value
Wrong currencyRevenue in the wrong currency in GA4currency missing or hardcodedRead ecommerce.currency from the dataLayer on every event tag
Events stop after consent changesGA4 goes quiet for EEA trafficConsent Mode v2 defaults to denied and no consent banner update reaches GTMWire the consent banner to GTM's consent API and test with a fresh EEA session
Import failsInvalid container or missing tags on importWrong file, or merging into a workspace with conflicting namesRe-download from the builder, import into a fresh workspace first, then merge with rename on conflict

The import-error case is worth a note of its own: if GTM rejects the file, do not edit the JSON by hand. Re-download it from the builder and import into a new workspace — a hand-edited container file is the fastest way to create triggers that point at variables that no longer exist.

How to test before you publish

  1. GTM Preview mode: connect to the store, walk the full journey, and confirm each event appears and fires its tags. Anything that fires on the wrong trigger is visible here before a single real visitor is affected.
  2. GA4 DebugView: with Preview running, open DebugView and confirm the test purchase shows transaction_id, value, currency and the items array. A purchase without an items array will not appear in product revenue reports.
  3. A real test order: place an order with a test payment method and refund or cancel it afterwards. A test order is the only check that covers the payment gateway redirect — the step where most purchase tracking actually breaks.
  4. Meta Test Events / Google Ads diagnostics: confirm the same purchase arrived on the ad platforms, not just in GA4. One platform receiving the event while another misses it points at a tag configuration problem, not a dataLayer problem.
  5. Tag Assistant or a tag debugger: confirm googletagmanager.com/gtm.js loads exactly once per page.
Google Tag Manager triggers list showing Custom Event triggers for View Item, Begin Checkout, Add to Wishlist, Form Submission and Calendly Booking Scheduled, plus the All Pages Page View trigger
The matching triggers — one Custom Event trigger for each dataLayer event, plus All Pages for the configuration tag. In Preview mode, check these names against the events your store pushes.
Google Tag Manager variables list showing Data Layer Variables for ecommerce, ecommerce items, value, transaction ID and currency, plus the GA4 Measurement ID constant variable
The variables that read the ecommerce data layer — items, value, currency and transaction ID — plus the constant that holds the GA4 Measurement ID.

Frequently asked questions

Do I still need the GTM4WP plugin if I use the builder?

Yes, for the dataLayer. The builder generates the GTM container — tags, triggers and variables. GTM4WP (or equivalent custom code) generates the dataLayer events the container listens to. The two do different jobs; using both is the standard setup, and you should never run two dataLayer plugins at once.

Why is my WooCommerce purchase event not firing in GA4?

Work backwards: does the thank-you page push a purchase event to the dataLayer (check in GTM Preview)? Does a custom event trigger match that exact name? Does the GA4 event tag read ecommerce variables that exist? And did the payment gateway return the customer to the thank-you page at all — a redirect that drops the customer elsewhere means the push never runs.

Why are my WooCommerce purchases counted twice?

Usually the thank-you page fires purchase again on refresh, or the container loads twice, or browser and server both send the event without a shared deduplication ID. Fix the dataLayer flag first — it is the most common cause — then check for a doubled container, then check server-side deduplication.

Can I track Google Ads and Meta purchases from the same container?

Yes. Add one conversion tag per platform on the same purchase trigger, all reading the same value, currency and transaction_id. That keeps every platform's numbers tied to the same order, which is what makes return-on-ad-spend figures comparable.

Which events should a new store set up first?

page_view, view_item, add_to_cart, begin_checkout and purchase, in that order. Those five give you the full funnel: who looked, who intended to buy, who started checkout and who paid. Add view_item_list and form_submission once the funnel is verified.

Share with