Websites and builders
WooCommerce
WooCommerce analytics with Stickybeak tracks checkout visits and non-failed orders with their total, currency and order number. It is a lighter alternative to Google Analytics for WooCommerce and takes about 10 minutes to set up.
You need a child theme's functions.php or a PHP snippets plugin such as WPCode.
Add the script
Open the WordPress header
With WPCode, go to Code Snippets → Header & Footer → Header.
Paste and save
<script defer data-site="YOUR_SITE_ID" data-domain="example.com" src="https://app.usestickybeak.com/_cfw/s.js" ></script>
Check it's working
Clear WordPress caches, then open the live shop in a private window. Confirm the script also appears on an Order received page, then follow Verify your install.
Track goals
Add data-goal to theme or block markup, or use ⚙ Settings → Goals → a page visit for /cart and /checkout. Do not attach revenue to these steps. See Custom goals.
Track purchases
WooCommerce conversion tracking
In WPCode, choose Code Snippets → + Add Snippet → Add Your Custom Code (New Snippet) → PHP Snippet, with Auto Insert → Run Everywhere. Or use your child theme's functions.php:
add_action( 'wp_footer', function () {
if ( ! function_exists( 'is_order_received_page' ) || ! is_order_received_page() ) return;
$order = wc_get_order( absint( get_query_var( 'order-received' ) ) );
$key = isset( $_GET['key'] ) ? wc_clean( wp_unslash( $_GET['key'] ) ) : '';
if ( ! $order || ! hash_equals( $order->get_order_key(), $key ) || $order->has_status( 'failed' ) ) return;
$purchase = array(
'revenue' => (float) $order->get_total(),
'currency' => $order->get_currency(),
'order_id' => (string) $order->get_order_number(),
);
?><script>
window.stickybeak = window.stickybeak || function () { (window.stickybeak.q = window.stickybeak.q || []).push(arguments); };
window.stickybeak('purchase', <?php echo wp_json_encode($purchase); ?>);
</script><?php
} );
Activate and save, then place a test-mode paid order. The total includes tax and shipping; use get_subtotal() for products only. order_id prevents repeat counts and respects sequential-number plugins. Never send customer details. See Revenue.
Pending, on-hold and processing orders may count; failed orders do not. For settled revenue, send from a payment or order-status integration. Privacy mode counts the goal but removes amount, currency and order ID.
If it isn't working
- Exclude
_cfw/s.jsfrom script delay, merging and optimisation. - Exclude
/checkout/*from page caching. - Test a total above zero in a private browser that is not excluded.
- The code supports classic and block Checkout and Order Confirmation.
See Troubleshooting.