Skip to main content

WooCommerce

TraceLog captures WooCommerce revenue from the order the customer just completed, reading the real amount paid from WooCommerce's own order object — never a guessed or placeholder value.

There are two ways to install it, and one advanced option:

  • TraceLog plugin (recommended) — upload a plugin, paste your Project ID, done. No code.
  • PHP snippet (developer) — a woocommerce_thankyou hook you add to your theme.
  • Server-side events (advanced) — forward WooCommerce order webhooks from your backend for 100% consent-independent capture.

Coverage matrix

PathRevenue captureCode requiredSetup timeConsent dependent?
TraceLog plugin (recommended)Client-side, on the order-received pageNone~2 minYes
PHP snippet (developer)Client-side, on the order-received pageTheme edit~5 minYes
Server-side events (advanced)100%, server-to-serverBackend webhookVariesNo
Capture honesty

The plugin and the PHP snippet both fire in the customer's browser on the order-received (thank-you) page, so they need that page to load and analytics consent to be granted — the same trade-off as any client-side pixel. Unlike Shopify's server-side order-paid webhook, there is no native WooCommerce server-side path in the wizard. If you need consent-independent 100% capture (including customers who close the tab before the thank-you page renders), use server-side events.

A small WordPress plugin that does two things once you paste your Project ID:

  1. Installs base tracking site-wide — it injects the standard @tracelog/lib browser snippet in the <head> of every page, identical to the one the dashboard hands out. You do not need to add the tracking script separately. If your site already loads TraceLog — through Google Tag Manager, a theme edit, or a snippet plugin — see Already tracking? below before you activate.
  2. Reports revenue automatically — on the WooCommerce order-received page it sends one purchase event carrying the order total, currency, order number, and line items. Because it emits the canonical purchase event with a value field, no revenue-mapping step is needed in the dashboard.

Install

  1. Download the plugin .zip from the revenue setup wizard in your TraceLog dashboard (select WooCommerce as your platform → Download the plugin).
  2. In WordPress admin, go to Plugins → Add New → Upload Plugin, choose the .zip, click Install Now, then Activate.
  3. Go to Settings → TraceLog, paste your Project ID (from Tracking → Install in the dashboard), and Save Changes.
  4. Place a real test order. Revenue appears in your TraceLog dashboard within seconds.

You can toggle Enable TraceLog tracking off at any time to pause tracking without uninstalling.

Already tracking?

If TraceLog is already loaded on your site some other way — Google Tag Manager, a theme edit, or a snippet plugin such as WPCode — tick Base script → "The TraceLog script is already installed on this site" in Settings → TraceLog. The plugin then reports revenue and leaves the existing script alone.

Do this instead of deleting your current snippet: removing it leaves a window where nothing is tracked, and the plugin's option achieves the same result with no gap.

Two copies of the library on one page do not merge into one. Each <script> tag loads and runs its own copy, so the store records every page view, click and scroll twice — inflating engagement metrics and consuming your plan's monthly event allowance at double rate. (Order revenue is unaffected: the purchase event fires once per order regardless.)

Leave the box unticked if nothing else on the site loads TraceLog — which is the normal case, and the default. The plugin needs to add the script for anything to be tracked at all.

How revenue stays correct

  • Real value, never a placeholder — the amount comes from WooCommerce's server-authoritative $order->get_total() (in your store's major currency units, e.g. 129.90, never cents), with the order's own currency.
  • Counted exactly once — a per-order guard means a page refresh on the thank-you page can never double-count an order. It is written through the WooCommerce order API, so it is correct whether or not you use High-Performance Order Storage (HPOS).
  • Never fatal — with no Project ID, tracking disabled, or WooCommerce inactive, the plugin emits nothing; it never white-screens your store.

Compatibility

WordPress 6.0+, PHP 7.4+, WooCommerce 7.1+. The plugin declares High-Performance Order Storage (HPOS) compatibility.

Developer fallback: the PHP snippet

If you prefer to own the code, the revenue wizard generates a woocommerce_thankyou hook you can drop into your theme. It fires the same client-side purchase event as the plugin, but it only handles revenue — it does not install base tracking.

  1. Make sure the TraceLog base script is already installed site-wide (Tracking → Installation in the dashboard).
  2. Add the generated snippet to the end of your theme's functions.php (or a code-snippets plugin). It goes alongside the base script — it does not replace it, and nothing you already installed needs removing.
  3. Place a real test order — the verifier turns green within seconds.
Pasting into a snippet plugin

Some snippet editors (WPCode among them) already put <?php on the first line for you. If yours does, paste from the /** comment block onward and leave that opening tag alone — two <?php tags in one snippet is a fatal PHP error, and on a live store that means a white screen.

The generated snippet reads $order->get_total(), $order->get_currency(), and the order number, and carries the same per-order dedup guard as the plugin, so it never reports an example value and never double-counts a refresh.

tip

Choose the PHP snippet only if you can't (or don't want to) install a plugin. For every other store the plugin is faster and safer — it's one upload instead of a theme edit, and it survives theme changes.

Advanced: server-side capture

Client-side capture misses orders where the customer never reaches the thank-you page (a closed tab, a declined consent banner, an off-site payment redirect that doesn't return). For 100% consent-independent capture, forward WooCommerce's server-side order webhook to TraceLog from your backend:

  1. In WooCommerce, add a webhook (Settings → Advanced → Webhooks) for the Order updated / completed topic, pointing at your own backend.
  2. In your handler, when an order reaches a paid/completed status, POST it to the TraceLog Server-Side Events API using event_name: "purchase" and the order total as the value field.
  3. Use the WooCommerce order ID as the event_id so retries are idempotent.

This is the same pattern as the Stripe integration and gives you the strongest revenue guarantee. Run it instead of the client-side paths, not alongside them, to avoid double-counting.

Verification

After installing, place a test order and check your TraceLog dashboard:

  1. The purchase event appears in the Events catalog.
  2. Tracking → Track your revenue shows revenue verified with the recovered order value.

If revenue doesn't verify, see Revenue Tracking → When revenue won't verify.

Campaign attribution

Because the plugin installs base tracking site-wide, browsing sessions carry their UTM parameters, and the purchase event stitches to the session that produced it — so revenue is attributed to the originating campaign, source, and medium automatically. See Revenue Tracking → Campaign Attribution.

Refunds

The client-side purchase event fires on new orders, not refunds. To subtract refunds from revenue, AOV, and revenue-by-channel, send them through the Server-Side Events API using your purchase event name with a negative amount.

Currency

Revenue is tracked in a single currency per project. The plugin sends each order's own WooCommerce currency; make sure your store currency matches the currency configured for the project so revenue isn't mixed across currencies.