Install Statsdot on WooCommerce
Updated October 16, 2026
WooCommerce runs on WordPress, so the snippet goes in exactly as in the WordPress guide: a header plugin or your child theme. Read its part on caching plugins too, since shops often use them.
Count purchases
The easiest way is the Statsdot plugin for WordPress: with WooCommerce it sends a Purchase event once per order, with the order total and currency, so the dashboard shows revenue per source, channel and campaign. Without the plugin, do it by hand as below.
The order received page has the order number in its address (/checkout/order-received/123/), and Statsdot matches page goals by their exact path. So instead of a page goal, send an event when that page loads. Add this to your child theme's functions.php or as a PHP snippet in a plugin such as WPCode:
add_action('woocommerce_thankyou', function ($order_id) {
if (! $order_id) {
return;
}
$order = wc_get_order($order_id);
$revenue = wp_json_encode(['revenue' => (float) $order->get_total(), 'currency' => $order->get_currency()]);
echo "<script>document.addEventListener('DOMContentLoaded', function () { window.statsdot && window.statsdot.track('Purchase', null, $revenue); });</script>";
});
The snippet in the head loads with defer, so the event waits for DOMContentLoaded, when the script is ready. The order total is sent as revenue (see Revenue). Do not add the order number or the customer's name as a label: Statsdot works without personal data, and your events should too. Reloading the thank-you page sends the event again; the plugin prevents that, this snippet does not. To ignore repeats and be able to delete test orders for 7 days, add 'id' => (string) $order->get_order_number() (see Revenue for what Statsdot keeps).
If an optimisation plugin delays JavaScript, exclude this inline script as well as statsdot.com/js/script.js.
Turn it into a goal
In the site's Settings (the cog next to the dates), add a goal of type Event with the name Purchase. The dashboard then shows how many visitors bought and the conversion rate over all visitors. If a customer reloads the thank-you page, the event is sent again, but the goal still counts that visitor once.
The steps before
The cart and checkout pages have fixed paths, so they work as page goals. WordPress paths end with a slash: /cart/ and /checkout/. With the three goals you can see how many visitors open the cart, start the checkout and complete the order.
More in Events and goals.