WooCommerce

WooCommerce dataLayer for GA4 and Google Ads: Plugin vs Custom Setup

In short: a WooCommerce dataLayer is the list of shop events (view_item, add_to_cart, begin_checkout, purchase…) that your site pushes to Google Tag Manager, with the product and order details GA4, Google Ads and Meta need. For most stores a well-known WordPress plugin is enough; build it yourself when you need full control, custom checkouts or server-side purchase events.

If you want it set up for you, see my WordPress dataLayer service.

The events GA4 expects from a WooCommerce store

EventWhen it firesKey fields
view_item_listCategory or shop pageitems
view_itemProduct pageitems, value, currency
add_to_cartProduct addeditems, value, currency
view_cartCart pageitems, value
begin_checkoutCheckout pageitems, value, coupon
add_shipping_info / add_payment_infoCheckout stepsshipping_tier / payment_type
purchaseOrder received pagetransaction_id, value, tax, shipping, currency, items

Each item should include at least item_id (SKU or product ID), item_name, price and quantity. Add item_variant, item_category and item_brand when you have them.

Example purchase push:

window.dataLayer = window.dataLayer || [];
dataLayer.push({ ecommerce: null }); // clear the previous ecommerce object
dataLayer.push({
  event: 'purchase',
  ecommerce: {
    transaction_id: 'WC-10452',
    value: 129.00,
    tax: 21.50,
    shipping: 5.00,
    currency: 'EUR',
    items: [{ item_id: 'SKU-881', item_name: 'Linen Shirt', price: 59.00, quantity: 2 }]
  }
});

Option 1: use a WordPress plugin

Plugins such as GTM4WP (Google Tag Manager for WordPress) can output a GA4-style WooCommerce dataLayer without writing code.

Good when: a standard WooCommerce theme and checkout, mainstream payment gateways, and you mainly need GA4 and Google Ads.

Check after installing:

  • The purchase event fires once on the order-received page, with the right order ID and value.
  • Prices include or exclude tax the way you report revenue.
  • The event still fires when the payment gateway sends the buyer back from an external page.

Option 2: build the dataLayer yourself

Custom code (in your theme or a small plugin) using WooCommerce hooks gives you full control.

Good when: a custom or headless checkout, subscriptions, multi-currency, several payment gateways, or you need extra fields (customer type, margin, coupon).

Typical approach:

  • Output product data on product and category templates.
  • Listen for cart changes (including AJAX “add to cart” buttons).
  • Push purchase on the order-received page from the order object, and mark the order as tracked so a reload doesn’t send it again.

Option 3: add server-side purchase events

Browser events can be lost to ad blockers, closed tabs or gateways that never return the buyer to your site. For important stores, send the purchase from the server as well (for example from the order status hook through server-side GTM or the GA4 Measurement Protocol), using the same transaction_id so GA4 and Meta can de-duplicate. See my server-side tracking guide.

Common WooCommerce dataLayer mistakes

  1. Duplicate purchases when the thank-you page is reloaded or opened again from an email. Fix: send transaction_id and only push once per order.
  2. Missing purchases with gateways that don’t return to the order-received page. Fix: server-side purchase event.
  3. Cached thank-you pages. Some caching plugins cache the order page. Exclude checkout and order-received pages from cache.
  4. Wrong revenue because tax or shipping is included in one tool and not the other. Decide once and match GA4, Google Ads and your reports.
  5. Not clearing the ecommerce object between events, which mixes items from earlier pushes.
  6. Prices sent as text with currency symbols (“€59.00”). Send numbers.

Missing purchases already? Start with my checklist: WooCommerce GA4 missing purchases.

Frequently Asked Questions

Do I need a plugin to get a WooCommerce dataLayer?

No, but it’s the fastest route for standard stores. A custom dataLayer is better for custom checkouts, subscriptions or extra fields.

Which events matter most?

purchase matters most, then add_to_cart and begin_checkout. Without a correct purchase event, GA4 revenue and Google Ads bidding are wrong.

Why does GA4 show more purchases than WooCommerce?

Usually because the purchase event fires again when the order page is reloaded. Sending a unique transaction_id and firing once per order fixes it.

Why does GA4 show fewer purchases than WooCommerce?

Ad blockers, consent choices, closed tabs and payment gateways that don’t return to your site. A server-side purchase event recovers most of these.

Can the same dataLayer feed Meta and Google Ads?

Yes. In GTM, the same ecommerce events can trigger GA4, Google Ads and Meta tags. Use the same order ID everywhere for de-duplication.

Direct Implementation White-Label for Agencies

Need this implemented, audited, or white-labeled?

Whether you are an eCommerce brand owner fixing signal loss or a digital marketing agency needing a senior analytics engineer under strict NDA, I deliver 24–48h SLA turnaround with 8.5+ EMQ match rates.

✓ 24–48h Emergency SLA ✓ Strict Non-Solicitation & NDA ✓ 8.5+ Event Match Quality
Jobair Mahmud

Jobair Mahmud

AI-Driven Performance Marketing & Web Analytics Consultant

Helping eCommerce brands and marketing agencies trust their ads data, scale Smart Bidding, and eliminate wasted ad spend through bulletproof server-side tracking and PPC management.