What this method tracks
What it can’t track
- Sign-ups before payment. The referral only exists once someone completes checkout. If you want it recorded at sign-up, you need the Session API method.
- A button that finished loading before the referral identifier was ready. Both load independently, so this needs verifying rather than assuming — see make sure the identifier arrived.
- A referral identifier Stripe rejects. Stripe accepts only letters, numbers, dashes and underscores here, and drops anything else silently while the button carries on working normally. Keep affiliate codes plain — no spaces, dots or accented characters.
- A button inside an iframe or a third-party widget. Code on your page can’t reach inside those.
- A buyer who switches devices between clicking the referral link and paying.
- A buyer whose browser blocked the script, or who cleared their cookies in between.
- A purchase after the cookie window closed. See tracking methods.
- Live payments while you’re connected in test mode, and the reverse. Referly deliberately ignores the mismatched ones.
Before you start
A Stripe account you can log into as an administrator
Somewhere to paste code on your site
head section of your pages, and to place the button where you want it.Your commission plan set up
Step 1: Create your buy button in Stripe
Skip this if your button is already on your site.Open Payment Links in Stripe
Pick or create a link
Switch it to a buy button
Turn on promotion codes if your affiliates use them
Copy the embed code
Step 2: Install the tracking script
The tracking script records clicks and remembers which affiliate sent each visitor. Nothing works without it. Open Integrations from the left sidebar, find the Stripe Buy Button card, and select it. The guide that opens has your script already filled in with your program’s ID. Copy that snippet and paste it into thehead section of every page on your site — especially any page with a buy button. It looks like this:
Step 3: Connect your Stripe account
Connecting Stripe is what lets Referly hear about payments. You don’t create API keys and you don’t set anything up by hand — you authorize Referly’s app from inside Stripe.Open the connect dialog
Choose live or test
Authorize Referly in Stripe
Confirm the connection
Step 4: Add the buy button snippet
This is the piece that does the work. It waits for the referral identifier, then adds it to every buy button on the page so it travels with the customer into Stripe’s checkout. Copy it from the Stripe Buy Button guide on the Integrations page and paste it into thehead section, after the tracking script from Step 2. Order matters — the snippet needs the tracking script to have loaded first.
Make sure the identifier arrived
This is worth doing properly rather than assuming. Your buy button is drawn by Stripe’s own code, and the visitor’s referral identifier is fetched by Referly’s code. The two happen independently, so the only way to know they lined up is to check — in two places.Visit the page through a referral link
your-domain.com?ref=THEIRCODE.Inspect the button element
stripe-buy-button element in your page. It should now carry a client-reference-id attribute with a value in it.Then confirm with a real test purchase
If the identifier never lands
If your test purchase shows an empty Client reference ID in Stripe, the button had already finished loading before the identifier was ready. Set the attribute yourself and hold the button back until you have a value:buy-button.js script tag on the page as well — this only replaces the button element, not the script that powers it.
Step 5: Test the whole flow
Test before you send a single affiliate link out, with your Stripe connection showing the yellow Test Mode badge.Switch Stripe to a sandbox and make a test button
Visit the page through a referral link
Check the attribute is set
client-reference-id with a value.Buy with a test card
4242 4242 4242 4242, any future expiry, and any three-digit security code. The full list is in Stripe’s testing guide.Confirm it in Stripe
Confirm it in Referly
Go live
- On the Integrations page, open the Stripe panel and select Disconnect.
- Select Connect Stripe Account and authorize your live account.
- Confirm the badge is green and reads Connected.
- Swap the test button embed code on your site for the live one, including the live publishable key.
Troubleshooting
The attribute is there but Stripe's Client reference ID is empty
The attribute is there but Stripe's Client reference ID is empty
Nothing appears in Referly at all
Nothing appears in Referly at all
The referral appeared but there's no reward
The referral appeared but there's no reward
The wrong affiliate got the sale
The wrong affiliate got the sale
Renewals aren't paying commission
Renewals aren't paying commission
The sale showed up late
The sale showed up late