Track affiliate sales on headless Shopify (Hydrogen) with an API
June 5, 2026 · 6 min read
Most affiliate apps track sales with a discount code or a checkout pixel. On a headless storefront (Shopify Hydrogen, a custom React app, or a separate frontend) that flow can break — your frontend isn't the one Shopify renders, and you may run a custom checkout. The fix is a server-to-server conversion API: your backend tells the affiliate platform about each sale, with the affiliate it should be credited to.
How attribution normally works
An affiliate shares a link (carrying a referral code) and/or a unique discount code. A click sets a cookie; a checkout with the code, or a last-click pixel, attributes the order. On a standard Shopify storefront this is automatic. Headless adds a wrinkle: you control the storefront and sometimes the checkout, so you want to report conversions explicitly rather than rely on the storefront pixel alone.
The conversion API approach
Capture the affiliate's referral code on landing (from the URL, e.g. ?ref=JANE) and persist it for the session. When an order is paid, your backend POSTs the sale to the affiliate platform with the order id, amount, and that referral code. The platform attributes it and computes commissions across your tiers. It's idempotent by order id, so retries are safe, and it never needs customer PII.
Example
With Override, that's a single authenticated request:
- POST /api/v1/conversions with { orderId, amount, currency, ref }
- Optionally include a customerId (hashed, never stored) so repeat orders can recur to the original affiliate.
- Authenticate with a bearer API key created in the app.
Webhooks for the other direction
Use outbound webhooks to push affiliate events into your own systems — a new affiliate to your CRM, a conversion to your data warehouse, a payout to Slack. Payloads are signed (HMAC-SHA256) so you can verify them. Together, the conversion API plus webhooks let you run a full affiliate program on any stack, not just a standard Shopify theme.
Do it with Override
Override's developer API (REST + webhooks + headless conversion ingest) is included on the Scale plan, with full docs and examples. It's the same engine that powers the native Shopify integration — so headless stores get multi-tier overrides, recurring commissions, bonuses and fraud protection, just driven by your backend.














