Skip to main content
Stripe Payment Links are the shareable checkout URLs that look like buy.stripe.com/.... You create them in the Stripe Dashboard, drop them on your site as buttons or links, and Stripe handles the rest. No backend code, which is exactly why so many people use them. Referly tracks them by adding the referral identifier onto the end of the link before the visitor clicks it. There’s a snippet that does this for you automatically, so you never have to touch the links themselves.
If you create your checkout from your own backend code instead, use the Stripe Session API method — it’s more precise. Using a pricing table or a buy button? See Stripe Pricing Table and Stripe Buy Button.

What this method tracks

What it can’t track

Payment Links are less precise than the Session API method, and the gaps are worth knowing before you launch.
  • A link the snippet can’t see. The snippet rewrites buy.stripe.com links that are on the page as ordinary links. A link built by a button’s click handler, opened inside a pop-up widget, or living in an iframe won’t be rewritten. See when the snippet won’t reach your links.
  • A link shared outside your site. If an affiliate posts your raw Payment Link in a newsletter or a Discord message, there’s no page for the snippet to run on and no referral is recorded. Affiliates should always share their Referly link, which points at your site.
  • A referral identifier Stripe rejects. Stripe only accepts letters, numbers, dashes and underscores here, and silently drops anything else. If your affiliates’ codes contain spaces, dots or accented characters, attribution fails quietly. Keep codes plain — see referral links.
  • 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.
  • Sign-ups before payment. Unlike the Session API method, there’s no way to record a referral at sign-up. The referral only exists once someone reaches checkout.
  • Live payments while you’re connected in test mode, and the reverse. Referly deliberately ignores the mismatched ones.

Before you start

1

A Stripe account you can log into as an administrator

You’ll authorize Referly from inside Stripe, so you need permission to connect apps.
2

Somewhere to paste two snippets

You need to be able to add code to the head section of your pages — through your site builder’s custom code area, your theme settings, or Google Tag Manager.
3

Your commission plan set up

Have it ready before the first sale arrives so rewards calculate correctly. See affiliate program setup.
Skip this if your links already exist.
1

Open Payment Links in Stripe

In the Stripe Dashboard, open Payment Links from the left menu.
2

Create the link

Select New, choose an existing product or select Add a new product and fill in its name and price, then select Create link. Stripe’s own walkthrough is in their create a payment link guide.
3

Turn on promotion codes if your affiliates use them

In the link’s settings, enable the option that lets customers enter a promotion code at checkout. Without it, an affiliate’s promo code can’t be used on that link. See coupons and promo codes.
4

Copy the link

Copy the buy.stripe.com address and put it on your site as a normal link or button.
You don’t need to change anything about the link itself for Referly. The identifier is added at the moment a visitor is about to click it.

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 Payment Links 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 the head section of every page on your site — especially any page with a payment link on it. It looks like this:
Copy the snippet from your dashboard rather than from this page. Your program ID is unique, and programs run by an agency load the script from a different address.
If you use Google Tag Manager, the same guide has a Tag Manager version. Add it as a Custom HTML tag firing on all pages.

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 up anything by hand — you authorize Referly’s app from inside Stripe.
1

Open the connect dialog

On the Integrations page, select Connect Integration at the top right, then choose Stripe.
2

Choose live or test

Select Connect Stripe Account for your real account, or Connect Test Mode to connect a sandbox first. Testing first is the safer order.
3

Authorize Referly in Stripe

A Stripe page opens in a new tab. Sign in, pick the account from the account picker at the top, and confirm. If you’re connecting test mode, make sure a sandbox is selected — Stripe explains sandboxes in their test mode guide.
4

Confirm the connection

Back in Referly, the Stripe panel shows a green Connected badge with your account name, or a yellow Test Mode badge for a sandbox.
The badge colour decides which payments count. Yellow Test Mode means real payments are ignored. Green Connected means test payments are ignored. This is the most common reason a correct setup appears to record nothing.
This is the piece that does the actual work. It watches for the referral identifier, then adds it to every buy.stripe.com link on the page so the information travels with the customer into Stripe’s checkout. Copy it from the Stripe Payment Links guide on the Integrations page and paste it into the head section, after the tracking script from Step 2. Order matters — the snippet needs the tracking script to have loaded first.
The snippet needs jQuery, which is why the first line loads it. If your site already loads jQuery, delete that first line — loading it twice can break other scripts on your page.
The same snippet also handles pricing tables and buy buttons, so you only need it once even if you use all three.

Check that it’s working

Open your site with a referral link, for example your-domain.com?ref=THEIRCODE, using a real affiliate’s code. Hover over your payment link button, or right-click and copy the link address. It should now end with client_reference_id= followed by a value:
If it doesn’t, jump to troubleshooting.

Adding the identifier by hand

If you’d rather not use the snippet — or your links live somewhere the snippet can’t reach — you can append the parameter yourself. This is what Stripe calls a payment link URL parameter.
Two rules to respect:
  • If the link already has a ? in it, use & instead of ? to add the parameter.
  • Only add the parameter when window.affiliateId actually has a value. Sending it empty is worse than not sending it.
The snippet finds links that are on the page as ordinary links when it runs. These situations need the manual approach above:
  • Buttons that redirect with code rather than being a real link. Read window.affiliateId inside your click handler and build the URL there.
  • Links added to the page after it loads — by a pop-up, an accordion, a modal, or a single-page app moving between views. The snippet stops looking a few seconds after the page loads.
  • Links inside an iframe or an embedded widget. Code on your page can’t reach inside those.
  • Links in emails or PDFs. There’s no page running, so nothing can be added. Send affiliates to a page on your site instead.
If you’re on a site builder like Webflow, Framer or Squarespace and your buttons are set up as normal links, the snippet works without any changes. It’s custom-coded buttons that need attention.

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.
1

Switch Stripe to a sandbox and make a test link

In the Stripe Dashboard, use the account picker at the top to switch into a sandbox, then create a Payment Link there. Test links and live links are different URLs, so put the test one on a test page.
2

Visit your site through a referral link

Open your site with a real affiliate’s link in a private window, for example your-domain.com?ref=THEIRCODE.
3

Check the link was rewritten

Right-click your payment button and copy the link address. It should carry client_reference_id= and a value. If it doesn’t, the problem is on your page, not in Stripe or Referly.
4

Buy something with a test card

Go through checkout with Stripe’s test card 4242 4242 4242 4242, any future expiry, and any three-digit security code. The full list is in Stripe’s testing guide.
5

Confirm it in Stripe

Open the payment in the Stripe Dashboard and check the Checkout Session shows your value in Client reference ID.
6

Confirm it in Referly

Open Referrals in the left sidebar — the customer should be listed against the right affiliate. Then open Rewards to see the commission.
When the referral shows the right affiliate and the reward shows the right amount, you’re done. Repeat once in live mode with a small real payment you refund afterwards — the refund should void the reward.

Go live

  1. On the Integrations page, open the Stripe panel and select Disconnect.
  2. Select Connect Stripe Account and authorize your live account.
  3. Confirm the badge is green and reads Connected.
  4. Swap your test payment links on the site for the live ones.
Referrals created during testing stay in your dashboard. Delete them before you launch if you don’t want test data in your reports.

Troubleshooting

Almost always the test-mode mismatch. A yellow Test Mode badge means live payments are ignored, a green Connected badge means test payments are ignored. Reconnect in the mode you’re actually testing in.If the badge is right, confirm the payment actually succeeded in Stripe.
Normal for a free trial or any checkout that hasn’t taken money yet — the reward is created when a payment succeeds. If a payment did go through, check the affiliate is on a commission plan that covers the product they sold.
Check whether a promo code was used at checkout. An affiliate’s promo code takes priority over the link, so someone who clicked one affiliate’s link but typed another’s code is credited to the code owner. You can move the sale by changing the referral’s affiliate.
Renewals are matched by the customer’s email address. Compare the email on the Stripe customer with the email on the referral in Referly — if they differ, the connection is broken.
If a payment arrives before Referly has finished creating the referral, it’s held and retried a few minutes later rather than dropped. Wait about ten minutes before assuming a sale is missing.

Stripe integration overview

Every way to connect Stripe, and which one fits you.

Stripe Session API

The more precise method, if you have a developer.

Stripe Pricing Table

Track referrals through an embedded pricing table.

Tracking methods

Set your cookie duration and how clicks are attributed.
Last modified on July 21, 2026