All articles

Shopify attribution

How to run a Shopify affiliate program without editing your theme

Start with affiliate discount codes and native paid-order webhooks. No theme.liquid change is needed until you want link attribution.

Published · Last reviewed

Written by Attribloom Engineering · Reviewed by Attribloom Product · Last reviewed

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.

Sources and verification

Primary documentation last checked on 2026-07-20. Each source below links the exact page and its own last-checked date.

Next steps

Frequently asked

Do I have to edit my theme to run a Shopify affiliate program?

No. The discount-code path needs no theme or storefront change. A theme.liquid edit is only required if you later add link attribution that credits a visit without a discount code.

What does the discount-code path miss?

It only credits a sale when the shopper enters the code. A shopper who came from an affiliate link but did not use the code is not attributed unless you add link attribution.

How is the commission amount calculated?

On the post-discount merchandise subtotal in the store's currency, excluding tax and shipping. Refunds reverse the matching share.

In the glossary

Continue reading

Get startedSee pricingMore articles