Docs for founders
Referral tracking setup
Affilicy never replaces your checkout. It reads payments from your Stripe account through the Affilicy Stripe App and decides which affiliate referred each paying customer. Promo codes work with Stripe alone; referral links also need one script on your website.
This guide as Markdown, for AI assistantsConnect Stripe and choose products
In Stripe & PayPal, install the Affilicy Stripe App on the account that bills your customers. Then open your app, go to Tracking and tick the products that belong to it. Payments for other products are ignored.
No webhooks or API keys to copy: the Stripe App sends Affilicy the payment events.
Choose promo codes, referral links or both
Promo codes
No script neededCustomers enter an affiliate's code at checkout and Stripe reports it. Your checkout only has to accept promotion codes.
Referral links
One script on your siteVisitors arrive through an affiliate's link. A small script on your site passes their code to Stripe, set up below.
Only using promo codes? You can skip the rest of this setup. Affiliates still get a link to share, but a click only counts once the script is on your site.
How a referral link reaches Stripe
Affiliate link
/r/max-1a2b
Your websiteYour part
?via=max-1a2b
Stripe checkout
client_reference_id
Commission
On actual payments
Your website has one job: hand the referral code to Stripe when checkout starts. After the first payment the customer stays with that affiliate, so renewals and upgrades follow your program terms without a code or link.
In the Claude desktop app or your IDE, send the text inside the quotes as your message instead.
Affilicy already connected to your assistant? Just ask: “Set up Affilicy tracking for my app in this project.” It reads your app's settings through the Affilicy connection.
Connect your AILoad the script on every page
Add it once to your shared layout or site-wide head.
data-daysis how long a referral is remembered; use your program's cookie duration.Webflow, Framer, WordPress and other builders: paste the HTML tag into the site-wide custom code for the head.
Pass the code to Stripe
Choose how your checkout starts. Using several? Cover each one.
Nothing to change. The script adds the referral to every
buy.stripe.comlink on the page, and again when one is clicked.Connect your consent banner
Remembering a referral in a visitor's browser is not strictly necessary for your site, so in the EU it needs consent (GDPR, TDDDG, ePrivacy). Until then the script stores nothing, and the code works only on the page the visitor landed on.
No EU visitors, or another legal basis you have checked? Add
data-consent="not-required"to the script tag to remember right away. Either way, list Affilicy referral tracking in your privacy policy.Test it
Open your site with a test code, then check the browser console.
https://yourapp.com/?via=test-codeThen start a checkout in Stripe test mode. The Checkout Session shows
test-codeas its client reference ID or in metadata asaffilicy_ref. No affiliate has that code, so nothing is attributed.
In the dashboard, your app's Tracking tab shows this guide with your website and attribution window filled in.
What earns commission
Affilicy looks for the referral in this order: an affiliate promotion code, then metadata.affilicy_ref on the subscription, invoice, customer or Checkout Session, then the session's client_reference_id.
- Only paid invoices and paid one-time Checkout Sessions. Trials, $0 invoices and failed payments never do.
- After the first payment the customer stays bound to the affiliate: renewals, upgrades and downgrades follow your program terms, with or without a discount on later invoices.
- Commission is calculated on the tax-exclusive amount actually collected for your mapped products.
- Refunds shrink or reverse unpaid commissions; disputes freeze them until resolved.
- Each commission is recorded once per invoice, however often Stripe retries a webhook.