WooCommerce gives you more control than Shopify — and more ways to break tracking. There’s no sandbox limiting what JavaScript you can run, but there’s also no native integration that “just works.” You’re responsible for getting conversion data to every ad platform accurately.
This guide covers the three approaches (plugins, GTM, and manual) for GA4, Meta, and Google Ads on WooCommerce.
What You Need to Track
At minimum, these ecommerce events should fire correctly:
| Event | When | Why |
|---|---|---|
page_view | Every page load | Session attribution, audience building |
view_item | Product page view | Retargeting audiences, funnel analysis |
add_to_cart | Product added to cart | Funnel tracking, cart abandonment |
begin_checkout | Checkout page loads | Checkout drop-off analysis |
purchase | Order confirmed | Revenue tracking, ROAS calculation |
Without these, your ROAS calculations are based on incomplete data, and platform algorithms can’t optimize your campaigns effectively.
Approach 1: Plugin-Based (Fastest)
The fastest way to get tracking running on WooCommerce. Several plugins handle the data layer, tag injection, and server-side events.
Recommended Plugins
For GA4:
- MonsterInsights — Most popular, handles GA4 ecommerce events. Free tier covers basics.
- GTM4WP — Pushes ecommerce data to the data layer for GTM. More flexible, requires GTM knowledge.
For Multi-Platform (GA4 + Meta + TikTok):
- TagFrog — All-in-one pixel management with server-side CAPI, consent management, and 11 platform support. Handles deduplication automatically.
- PixelYourSite — Meta Pixel + GA4 + Pinterest. Popular but basic server-side support.
Plugin quality varies wildly. The biggest risk is deduplication — many plugins fire both client-side pixel events AND server-side CAPI events without proper event_id matching, causing platforms to double-count conversions.
Plugin Setup Checklist
- Install and activate the plugin
- Enter your platform IDs (GA4 Measurement ID, Meta Pixel ID, etc.)
- Verify events fire on a test purchase (use GTM Preview Mode or browser DevTools)
- Check for duplicate events (two purchase events = double-counted revenue)
- Test with an ad blocker enabled (does server-side backup fire?)
Approach 2: GTM + Data Layer (Most Flexible)
Google Tag Manager with a WooCommerce data layer plugin gives you maximum control.
Step 1: Install GTM on WordPress
Follow our WordPress GTM setup guide if you haven’t already.
Step 2: Install a Data Layer Plugin
GTM4WP (by Thomas Geiger) is the standard. It pushes WooCommerce ecommerce data into the GTM data layer automatically:
- Install GTM4WP from the WordPress plugin directory
- Go to Settings → GTM4WP → Integration tab
- Enable WooCommerce tracking
- Set the data layer format to GA4
This makes ecommerce data available to GTM tags via data layer variables.
Step 3: Configure GA4 in GTM
Create these tags in GTM:
GA4 Configuration Tag:
- Tag type: Google Tag (gtag.js)
- Measurement ID: Your GA4 ID (G-XXXXXXX)
- Trigger: All Pages
GA4 Ecommerce Events: For each ecommerce event, create a tag:
- Tag type: GA4 Event
- Event name:
view_item,add_to_cart,purchase, etc. - Parameters: Map from data layer variables
- Trigger: Custom event matching the data layer push name
For complete GA4 event setup details, see our GA4 ecommerce tracking guide. Use our GA4 event reference to verify you’re using the correct event names and parameters.
Step 4: Add Google Ads Conversion Tracking
- Add a Conversion Linker tag firing on All Pages
- Add a Google Ads Conversion Tracking tag firing on the
purchaseevent - Map transaction value and ID from the data layer
Step 5: Add Meta Pixel
- Add a Custom HTML tag with Meta’s base pixel code → fire on All Pages
- Add event-specific tags for
ViewContent,AddToCart,Purchase - For server-side CAPI, use a plugin or server-side GTM
Approach 3: Manual Code (Full Control)
For developers who want direct control without plugins or GTM.
WooCommerce Hooks for Tracking
WooCommerce provides PHP hooks at each funnel step:
// Product page view
add_action('woocommerce_after_single_product', function() {
global $product;
// Push view_item event to data layer or fire pixel
});
// Add to cart
add_action('woocommerce_add_to_cart', function($cart_item_key, $product_id, $quantity) {
// Push add_to_cart event
}, 10, 3);
// Checkout page
add_action('woocommerce_before_checkout_form', function() {
// Push begin_checkout event
});
// Purchase complete
add_action('woocommerce_thankyou', function($order_id) {
$order = wc_get_order($order_id);
// Push purchase event with order data
}, 10, 1);
The Thank-You Page Problem
WooCommerce’s default thank-you page (/checkout/order-received/{order_id}/) has a gotcha: it can be reloaded. If a customer refreshes the page, your purchase event fires again.
Fix: Use a session flag or order meta to prevent duplicate fires:
add_action('woocommerce_thankyou', function($order_id) {
$order = wc_get_order($order_id);
if ($order->get_meta('_tracking_fired')) return;
$order->update_meta_data('_tracking_fired', '1');
$order->save();
// Fire tracking events
}, 10, 1);
Server-Side Tracking on WooCommerce
Client-side tracking misses 20-40% of conversions. Server-side closes the gap.
Option A: Plugin with CAPI Built-In
TagFrog, PixelYourSite Pro, and similar plugins handle server-side dispatch. They hook into WooCommerce’s order creation and send CAPI events automatically.
Option B: WooCommerce Webhooks
WooCommerce can send webhooks on order events:
- WooCommerce → Settings → Advanced → Webhooks
- Create a webhook for
Order created→ POST to your server - Your server processes the webhook and fires CAPI events
This is the same pattern Shopify uses for server-side tracking — the ecommerce platform notifies your server, which forwards to ad platforms.
Option C: Server-Side GTM
Route GTM events through a server-side container:
- Browser fires events to your sGTM endpoint (instead of directly to GA4/Meta)
- sGTM processes and forwards to all platforms
- Adds server-side identity data (hashed email, etc.)
Consent Management
WooCommerce sites need a consent banner for GDPR/CCPA compliance. Common CMPs:
- Complianz — WordPress-native, integrates with GTM
- CookieYes — Simple setup, free tier
- Cookiebot — Enterprise-grade, auto-detects cookies
Your tracking tags must respect consent signals. See our Consent Mode v2 guide for the complete setup with GTM.
Verification Checklist
- GA4 receives
page_viewon all pages - GA4 receives
view_itemwith product data on product pages - GA4 receives
add_to_cartwith correct item data - GA4 receives
purchasewith revenue, transaction ID, and items - No duplicate purchase events on thank-you page refresh
- Google Ads conversion tag fires on purchase (with value)
- Meta Pixel fires on all pages + purchase events
- Server-side CAPI sends purchase events
- Consent banner blocks tracking before consent
- Events fire correctly with ad blocker enabled (server-side)
If more than two boxes are unchecked, run a free tracking scan to identify exactly what’s missing.