Discount codes first
The fastest way to launch a Shopify affiliate program is to skip storefront code entirely. Connect your store, approve an affiliate, then create a Shopify discount whose code exactly matches the referral code on that affiliate's Attribloom detail page. Hand the code to the affiliate. When a shopper uses it at checkout, Shopify includes it in the paid order and Attribloom matches it to the affiliate.
Attribloom calls this a validated discount code: a Shopify checkout code that exactly matches an affiliate referral code already recorded in Attribloom. There is no theme edit and no storefront script involved.
How the sale is confirmed
Shopify emits HMAC-signed paid-order and refund webhooks from its own servers. Attribloom verifies the signature, reads the discount code, and credits the matching affiliate. Commission is calculated on the post-discount merchandise subtotal, excluding tax and shipping, and a refund reverses the matching share on a double-entry ledger.
- No storefront pixel: the order is confirmed from Shopify's server-side webhook.
- Commission basis: post-discount merchandise subtotal, excluding tax and shipping.
- Refunds, full or partial, reverse the matching commission automatically.
The limit of discount-code attribution
Discount codes only credit an affiliate when the shopper actually enters the code. A visitor who arrives from an affiliate link but checks out without the code is not attributed. If you want to credit a visit without asking the shopper to type a code, you add link attribution, which reads a ?ref parameter and preserves it on the cart. That is the one case that warrants a small theme.liquid change.
Most programs start code-only and add link attribution later, once the affiliate channel is worth the storefront change. The two paths can run together, and Attribloom fails closed if a discount code and a ref value ever identify different affiliates.