WooCommerce

Attribute sales to creators on WooCommerce — WordPress. Pixel on the thank-you page, or server-side from PHP.

Yonto attributes sales to the individual creator who drove them. On WooCommerce that works several ways, and the honest summary is that browser pixel does most of the work:

Browser pixel — primary on this platform
A small script on your confirmation page reports the order. Depends on the shopper accepting cookies and not blocking scripts.
Server-side API
Your backend reports the order to our API with a secret key. The most reliable path, and the most work.
Discount code
The shopper types the creator's code at checkout. Works on every platform and survives a refused cookie, but only catches shoppers who use it.

Setting it up#

Every campaign has its own tracking code. The snippets below use YOUR_TRACKING_CODE as a placeholder — copy the real ones from the campaign's Setup screen, which fills them in for you.

Conversions are reported from: The order-received (thank you) page.

  1. 1
    Add the pixel site-wide
    Appearance → Theme File Editor → header.php, just before </head>. Or use a header-scripts plugin if you would rather not edit the theme.
    html
    <script async src="https://yontosales.com/p.js" data-proof="YOUR_TRACKING_CODE"></script>
  2. 2
    Fire the conversion on the thank-you page
    Add this to your child theme's functions.php. It runs on the order-received page and passes WooCommerce's own order id and total.
    html
    add_action('woocommerce_thankyou', function ($order_id) {
      $order = wc_get_order($order_id);
      if (!$order) return;
      ?>
      <script>
        proof('conversion', {
          value: <?php echo esc_js($order->get_total()); ?>,
          id: '<?php echo esc_js($order->get_order_number()); ?>',
          currency: '<?php echo esc_js($order->get_currency()); ?>'
        });
      </script>
      <?php
    });
  3. 3
    Create a matching coupon
    Marketing → Coupons, named exactly as your campaign's code. This is what catches shoppers who refuse cookies.
Warning.on a sale campaign, value and id are both required. The order id is what makes a retry or a refreshed confirmation page idempotent instead of a second sale. A call missing either is rejected — see the Conversion endpoint reference.

What this can and cannot see#

Attribution is never complete, on any platform. You are about to pay a creator on the strength of these numbers, so here is exactly what is behind them on WooCommerce.

Counted
  • Orders completed in the same browser that clicked the link, within 30 days.
  • Orders that used the creator's discount code, whatever the shopper's cookie settings.
  • The order's real total and currency, straight from WooCommerce.
Not counted
  • Shoppers who refuse tracking cookies — the click is never linked to the sale.
  • Purchases made on a different device from the click.
  • Anyone running an ad blocker that blocks our script.
  • Sales where the shopper cleared their browser data between clicking and buying.
  • Refunds — WooCommerce refunds are not sent to Yonto, so a refunded order stays counted.

This is why every figure Yonto reports is described as a confident floor rather than a total. The sales in the right-hand column happened; we simply cannot prove the creator caused them, and we would rather undercount than invent.

Worth knowing#

  • If your theme caches the thank-you page, the conversion call may not run. Exclude order-received from caching.
  • For a more reliable path, report from PHP with the server-side API instead of the browser.

Making it more accurate#

  • Ask the creator to lead with the discount code. It is the only method that survives a shopper refusing cookies, and it converts better anyway.
  • Report from your backend instead of the browser. The server-side API sees orders that no browser-based method can.
  • Report refunds. WooCommerce does not tell us when you refund an order, so a refunded sale stays counted unless you reverse it yourself.
  • Use one discount code per campaign. Codes are matched before click ids, and a code shared across campaigns resolves to whichever matches first.