All guides

Affiliate discount codes: how coupon attribution works

A code per affiliate credits the sales a link misses: podcasts, videos, a friend telling a friend. How to set them up and how the sale is matched.

Updated · 9 min read

An affiliate link only works when someone clicks it. A lot of word of mouth never produces a click. A podcast host reads your name aloud, a developer mentions you in a conference talk, a friend tells a friend over lunch. The customer arrives a week later by typing your domain, and the affiliate who sent them gets nothing. An affiliate discount code fixes that. The customer types it at checkout, and the code says who sent them.

Why codes catch sales a link misses

A link depends on a chain of small things: the click, a cookie, the same browser, the same device, a checkout within the cookie window. A code depends on one thing: the customer typing it. That makes codes the better carrier wherever the recommendation is spoken or copied by hand.

  • Audio and video. Nobody types a tracked URL from a podcast. "Use SARAH20" is easy to remember and easy to say.
  • Phone to laptop. People hear about a tool on their phone and buy it at their desk. The cookie stays on the phone. The code goes wherever the customer goes.
  • Newsletters and communities. Links get stripped, shortened or pasted without their query string. A code survives being retyped.
  • Talks, slides, printed material. A code fits on a slide. A tracked link does not.

A code also gives the customer a reason to use it. A bare link asks for a favour. A discount gives something back.

One code per affiliate, or one discount for the whole program

There are two different things people call "affiliate coupons", and they do different jobs.

  • A code per affiliate (SARAH20, DEVTOOLSPOD) is a way to attribute a sale. The code belongs to one affiliate. When a payment uses it, that affiliate is credited. This is the one that recovers sales a link cannot see.
  • A program-wide discount is a perk. Everyone who arrives through any affiliate's link gets the same discount at checkout. The link still does the attribution. The discount gives the customer a reason to finish: a double-sided reward, where the customer saves and the affiliate earns.

Start with codes per affiliate. They solve the attribution problem. Add a program-wide discount later if you see referred visitors dropping off at checkout. Do not use one shared code for attribution. If every affiliate posts PARTNER20, you cannot tell whose audience bought.

How to name affiliate codes

A code is read aloud, typed on a phone and remembered for days. Name it for that.

  • Use the affiliate's name or show name. SARAH20 or SHIPITPOD. Their audience already knows the name.
  • Put the discount in it when it is fixed. If you change the discount later, issue a new code rather than leaving a misleading one live.
  • Keep it short and sayable. Letters and digits, 12 characters or fewer for the name part, nothing that is hard to say.
  • Avoid look-alike characters. O and 0, I and 1 cause failed checkouts and support emails.
  • Avoid generic words. SAVE20 and WELCOME are the first things people try at a checkout. A generic code gets found and credited to whoever owns it.
  • One code per campaign if you need it. An affiliate who runs a podcast and a newsletter can hold two codes, so you can see which channel sells.

Choosing the discount and the commission together

A discount and a commission both come out of the same sale. Set them together, not one after the other. The simplest way is to work out one customer's first year at full price, then with the code.

An illustrative example: a plan at $49 a month, a 30% recurring commission for 12 months, and a code worth 20% off for the first 3 months. The commission is a share of what the customer actually paid, so the discount reduces it too.

First 12 monthsWithout a codeWith the code
Customer pays12 × $49 = $588.003 × $39.20 + 9 × $49 = $558.60
Affiliate earns (30%)$176.40$167.58
You keep$411.60$391.02

The customer saves $29.40. You carry $20.58 of that and the affiliate carries $8.82, in proportion to the commission: about 5% of what you would have kept. If the code made the sale, or is the only way you would know who sent it, that is cheap.

  • Time-limit the discount. 20% off for 3 months costs far less than 20% off forever, and it still gets people through checkout.
  • Keep the commission worth promoting. If a big discount shrinks the commission to a few dollars, affiliates stop mentioning you. Raise the commission or lower the discount.
  • Check the first payment. If discount plus commission exceed what you can afford on a customer who cancels in month two, scale one back.
  • Be wary of 100% codes. A free first month brings in people who never pay. If you use one, make sure the commission waits for the first paid invoice.

How a code is matched to a sale

Your payment processor applies the discount. Your affiliate tool recognises it afterwards, from the payment event. That is where setups break: several processors name the discount on the event by an internal id, not by the code the customer typed. If your tool only knows SARAH20 and the event says promo_1Q…, the sale goes uncredited.

So register each code twice: the code as customers type it, and the processor's id for it. Then test one purchase with each new code before the affiliate announces it.

In Klibon, a code is entered on the affiliate's Coupons panel, exactly as customers will type it. Case does not matter. Stripe events carry the promotion code's promo_… id and the coupon's id. Paddle sends only the dsc_… id. Polar and Creem send both the id and the code. Adding the id makes the match certain. A matched sale then follows the same hold period and product rules as a sale from a link (Coupon codes).

It will happen. A customer clicks Affiliate A's link on Monday, hears Affiliate B's podcast on Thursday, and types B's code at checkout. Decide your rule now and put it in your terms.

The fair answer: on a new customer, the code wins. Typing a code is something the customer did on purpose, at the moment of buying. A cookie is something that happened to them days earlier. And a code should never move an existing customer to another affiliate, or anyone could claim your renewals by getting their code onto a customer's next upgrade.

Klibon applies the rules in this order:

  1. A customer already attributed stays with their affiliate, whatever the payment carries.
  2. A registered code on the payment credits its affiliate.
  3. The link's referral, carried by the cookie into checkout, credits the affiliate who shared it.

When the code and the link name different affiliates, the code's affiliate is credited and the event is marked Conflict in the event log, with the reason. You can see every case and explain it if an affiliate asks.

Code leaks and how to limit them

Good codes travel. Coupon sites and browser extensions collect them, and customers who were already buying find them. You then pay a discount and a commission on a customer you had anyway. You cannot stop leaks entirely. You can make them cheap and visible.

  • One code per affiliate. When a code leaks, you know whose it is and can replace that one code without touching the others.
  • Limit the discount to new customers where your processor allows it, so a leaked code cannot discount renewals or upgrades.
  • Time-limit the discount, and give codes an end date for one-off campaigns, such as a sponsored episode.
  • Watch for spikes. A code that suddenly sells far more than its affiliate's audience could explain has probably been posted somewhere. Search for it.
  • Put it in the terms. Forbid posting codes on coupon sites and bidding on your brand name in ads. Then you have grounds to act.
  • Retire and reissue. Switch the leaked code off and give the affiliate a new one. Customers they already brought in should stay theirs.

In Klibon, archiving a code stops new sales from matching it, and the customers it already brought in stay with the affiliate. For a code you created yourself in your processor, disable the discount there too. A blocked affiliate's codes stop matching, like their links. For the wider picture, see how to prevent affiliate fraud.

Setting up codes on each processor

The discount always lives in your payment processor, and you decide what it gives. What differs is who creates the code and which id your affiliate tool needs to match it.

ProcessorWho creates the codeWhat to register
StripeKlibon, automatically, or you by handNothing for automatic codes. For a manual one, the code and its promo_… id
PaddleYou, as a discount in PaddleThe code and its dsc_… id
PolarYou, as a discount in PolarThe code, plus the discount id
CreemYou, as a discount in CreemThe code, plus the discount id

On Stripe, you can skip making codes by hand. Create one coupon in Stripe, for example 20% off for 3 months, with no redemption limit. Then give Klibon a second, restricted key that can only read coupons and write promotion codes. The key used for tracking stays read-only. Every affiliate you approve gets a code made of their name and the discount, like SARAH20. Blocking or removing an affiliate switches their code off in Stripe for you. Connect Stripe covers the rest of the setup.

When a visitor arrives through an affiliate's link, the tracking script prefills that affiliate's code on the checkouts that accept one: a Stripe Payment Link, a Polar or Creem checkout link, a Paddle button. Make sure your checkout shows a discount field, so customers who heard the code can type it.

Codes per affiliate are on every plan, including Free. The program-wide discount for referred customers is on Growth and Scale (pricing). It is prefilled for anyone who arrives through any affiliate link, but it is a perk, not attribution, and one code cannot be both.

A short checklist

  1. Decide the discount and the commission together, on a full first year.
  2. Create one code per affiliate, named after them, restricted to new customers.
  3. Register each code with the processor's id, and test one purchase.
  4. Write your rule for links against codes, and for returning customers, into the terms.
  5. Watch each code's volume, and replace any code that leaks.

If you are still setting the program up, start with how to create an affiliate program.