Platforms

How to track WooCommerce sales by source, without a heavy plugin

Count WooCommerce orders with their source three ways: the order received page, your Stripe account, or a server webhook, and what each one misses.

On this page

WooCommerce runs on WordPress, so adding an analytics tag is a WordPress job; see how to track a WordPress site. The harder question is sales: which ad, email or post brought each order, with its value, counted once. WooCommerce has its own reports for orders and revenue, but they do not know where buyers came from.

This page covers three ways to count orders with their source, and what each misses. Sporetag has no WooCommerce connector; everything below works with what Sporetag does today.

Install Sporetag on WooCommerce

  1. In Sporetag, add your store's domain and copy the tag from Set up your site.
  2. In WordPress, add the tag to the header of every page with a header plugin such as WPCode, the same as any WordPress site.
  3. Clear your cache plugin's cache, if you use one.
  4. Open your store in a new tab and click Check my site in Sporetag.
  5. Add a Purchase goal, then pick one of the order methods below.

Method 1: the order received page

After a successful purchase, WooCommerce shows the Order received page, a checkout endpoint (WooCommerce). By default its address is your checkout page followed by /order-received/ and the order number (WooCommerce).

  • No code: count a visit to /checkout/order-received/* as a goal. It counts orders, without their value.
  • A few lines of code: on that page, send a purchase event with the order total and the order number as its event id. A WooCommerce developer can add it in a theme or snippet.

What it misses: buyers who pay with a method that sends them elsewhere and never come back, buyers who close the tab, and anyone whose browser blocks the tag. It also counts a reload of the page twice, unless the event id is the order number.

Method 2: your Stripe account

If your store takes cards with WooCommerce's Stripe extension, the payments are in your own Stripe account. A tool that reads Stripe sees each payment and refund with its amount, whether or not the buyer reached the order received page.

With Sporetag, the Stripe connector does this on paid plans, with a read-only restricted key. It matches each payment to a customer by email and phone, so a sale ties to earlier visits when that customer was identified on your site. For a direct tie to the visit, the visitor's _st_id cookie must reach the payment's metadata.st_id; the Stripe extension has documented filters for adding metadata, which a developer can use (WooCommerce).

What it misses: orders paid by PayPal, bank transfer or any other gateway.

Method 3: a webhook from WooCommerce

WooCommerce can send a webhook when an order is created or updated: WooCommerce, Settings, Advanced, Webhooks, then a topic, a delivery URL and a secret that signs each delivery (WooCommerce).

The webhook's body is WooCommerce's own order format, so it needs a small step in the middle that checks the signature and sends a purchase to your analytics in the shape it accepts. A Zapier or Make step, or a short script on your server, can turn a paid order into a call to Sporetag's Events API on paid plans, with:

  • the order number as event_id, so a retried webhook counts once,
  • the total and currency,
  • the buyer's email, which Sporetag hashes on arrival.

What it misses: nothing on the order side; every gateway is covered. To tie the order to the visit, pass the visitor's id or IP address and browser too.

Which one to use

StoreUse
Small store, no developerThe order received page, as a goal
Cards through StripeThe Stripe connector, plus the order received page
Several gateways, or you want every orderA webhook to the Events API

Use the same order id everywhere. With one id, a sale reported by the page and by the webhook is still one sale.

Common questions

Does Sporetag have a WooCommerce plugin or connector?

No. Sporetag counts WooCommerce orders from the order received page, from your Stripe account with the Stripe connector, or from a webhook sent to the Events API.

How do I track WooCommerce conversions without a plugin?

Count a visit to the order received page as a goal. It needs no code but has no order value. For values, send a purchase event from that page or from a webhook.

Why do my analytics show fewer orders than WooCommerce?

Some buyers never load the order received page, some block the tag, and some pay by a gateway that does not return them to your site. Server-side methods, such as Stripe or a webhook, close the gap.

What is the WooCommerce order received page URL?

By default, your checkout page followed by /order-received/ and the order number. The endpoint name can be changed in WooCommerce's advanced settings.

Sources

Spotted something wrong or out of date? Email hello@sporetag.com and we will fix it.