Affiliate tracking explained: how a link click becomes a commission

Affiliate tracking connects a partner's link click to a paid sale. 6 handoffs, 4 methods and 10 checks show how links and cookies work and where each leaks.

Muzahid Maruf — Founder of TrackRev.io

Muzahid MarufUpdated

Affiliate programs · 8 min read
On this page
  1. 01What an affiliate link means
  2. 02How affiliate tracking works, from click to commission
  3. 034 ways to track a referral
  4. 04Which partner gets the credit
  5. 05How to use an affiliate link as a partner
  6. 06Where affiliate tracking breaks
  7. 0710 checks to run on your own tracking
  8. 08What TrackRev does for affiliate tracking

Explore with AI

Opens this article inside the chosen assistant with a ready-made prompt.

Affiliate tracking records which partner's link a customer clicked and credits that partner when the customer pays.

The merchant's server logs the click and sets a visitor ID cookie, and a Stripe webhook later matches the payment back to that visitor.

6 handoffs sit between click and commission, and a failure at any one, from an Apple Safari cookie rule to a missing Stripe Checkout field, files the sale under direct.

Key takeaways

  • 6 handoffs connect a click to a commission, and a failure at any one files the sale under direct.
  • Safari 12.1 capped script-written cookies at 7 days in 2019. Save the visitor ID at signup so no cookie has to survive until the first payment.
  • Stripe takes the ID in client_reference_id (200 characters) or metadata (500-character values). Without one of them the webhook has nothing to match.

An affiliate link is an ordinary web address with a partner ID attached, such as ?ref=jane, go.acme.com/jane or the tagged link formats that Amazon Associates' operating agreement requires.

The merchant's system must read the ID, store it and match it to a payment days or weeks later.

The Federal Trade Commission's Endorsement Guides Q&A describes the partner's side: link to a retailer, earn a commission when a reader buys.

How affiliate tracking works, from click to commission

StepWhat happensWhat gets recorded
1A click on go.acme.com/jane reaches a redirect on the merchant's domainPartner, from the slug
2The server logs the click and marks bots so they earn no creditPartner, timestamp, user agent, referrer, visitor ID
3The server answers 302 with a Set-Cookie header, often with Max-Age=31536000Visitor ID in a cookie, often in the URL too
4Signup saves the ID, and payment creation writes it onto the Stripe Checkout SessionUser record; client_reference_id (200 characters)
5Stripe sends checkout.session.completed, then invoice.paid per invoiceCharge amount and ID at the webhook endpoint
6A matching job finds the click, applies the credit rule and the rateLedger row; a refund writes the reversal

A referral that pays on day 41

Take a partner named Jane on a 30% recurring commission and a $49 monthly plan (illustrative numbers). A visitor clicks her link on a Tuesday, signs up 5 days later and makes the first payment 41 days after the click.

DayEventWhat the match uses
0Click on go.acme.com/janeClick row and visitor ID from the redirect
5Signup with a new emailID copied to the user record beside the email
41First payment, $49ID on the Checkout Session; the click is 41 days old
71Second payment, $49Renewal inherits the first payment's credit

A 30-day cookie window would have closed 11 days before the first payment, and the sale would be filed as direct.

With a 60-day window the first payment earns Jane $14.70 ($49 × 0.30), and a customer who stays 12 months earns her 12 × $14.70 = $176.40. Lose the ID at day 41 and all $176.40 goes with it.

4 ways to track a referral

MethodMatched onTypical gap
Link and cookieVisitor ID in a cookieSafari deletes script-written copies after 7 days
Coupon codePersonal code on the discountThe customer has to type it, and a shared code credits 0 partners
PostbackClick ID from a network1 call per sale to the network, plus development work to carry the ID to payment
Email matchEmail saved at signupBuyer pays with a different address

Which partner gets the credit

Say a visitor clicks 3 partners' links (A on day 1, B on day 10, C on day 20) and pays $49 on day 21.

The credit rule decides who earns the 30% commission, and the attribution models comparison has the trade-offs.

RuleWho is creditedCommission on $49 at 30%
Last clickPartner C$14.70 to C
First clickPartner A$14.70 to A
SharedA, B and C equally$4.90 each

Use the link exactly as the partner dashboard issues it, since a shortener or an edited ID can drop it, and check in a private window that the landing address still carries the ID.

Audio and print have nothing to click, so ask for a personal coupon code.

Under the Federal Trade Commission's Endorsement Guides the commission should be disclosed close to the recommendation, and "affiliate link" alone may not be understood; see the compliance guide.

Where affiliate tracking breaks

Browser rules are the first place to look. Statcounter's September 2026 data puts Safari at 46.38% of US mobile browser use, 1.06 points behind Chrome's 47.44%.

RuleVersion and announcement dateEffect on a partner cookie
Script-cookie capApple Safari 12.1 and iOS 12.2, Feb 21, 2019 (Intelligent Tracking Prevention 2.1)Cookies created through document.cookie get a 7-day expiry cap
Link-decoration capiOS 12.3 and macOS 10.14.5, Apr 24, 2019 (ITP 2.2)1 day, when a classified tracker sent the visitor and the URL has a query string or fragment
Third-party blockSafari 13.1 and iOS 13.4, Mar 24, 2020Cookies for cross-site resources are blocked by default
PartitioningMozilla Firefox 86 (Strict mode), 90 (private windows), 103 (all users)Cookies are keyed to the top-level site, so a network's cookie does not follow the visitor between merchants

Sources: WebKit's ITP 2.1, ITP 2.2 and Safari 13.1 posts, and MDN's State Partitioning page.

WebKit's tracking prevention page now words the 7-day rule as deletion after 7 days without user interaction.

A cookie your own server sets in a Set-Cookie header sits outside it, and the click row in your own database is untouched by browser rules. In MDN's Set-Cookie reference Max-Age counts seconds, so the 31536000 below is 365 days.

A redirect response that records the visitor ID
HTTP/1.1 302 Found
Location: https://acme.com/pricing?_vid=3f6c9a52-81d4-4c0e-9a77-5b2f1de0a4c8
Set-Cookie: vid=3f6c9a52-81d4-4c0e-9a77-5b2f1de0a4c8; Max-Age=31536000; Domain=acme.com; Path=/; Secure; SameSite=Lax

Cookies that miss the checkout

A cookie set on www.acme.com with no Domain attribute is readable only on that host. Domain=acme.com shares it with app.acme.com, but a Stripe-hosted checkout usually sits on another registrable domain, so the ID must travel in the request.

Stripe offers 3 places to put it.

FieldLimitWhere it comes back
Checkout Session client_reference_id200 characterscheckout.session.completed
Metadata on a Stripe object50 keys, 40-character keys, 500-character valuesEvents for that object
Payment Link URL parameter200 characters of letters, digits, - and _The same event

A Payment Link silently drops an invalid value, so a UUID passes and an ID with a dot or an @ vanishes without an error.

Windows shorter than the sales cycle

TrackRev's program setup proposes 60 days and accepts 1 to 3,650. Choose yours from data: pull the last 100 paying customers, compute the days from first partner click to first payment, and set the window just past the 90th percentile.

If 90 of the 100 paid within 62 days, 75 days covers them with margin, while 365 days starts crediting clicks that played no part in the decision.

Webhooks and renewals

Stripe's webhook documentation sets the rules. invoice.paid fires on every successful invoice, so a handler that listens only for checkout.session.completed pays a partner once and misses each renewal, as the subscription tracking guide explains.

RuleValue
Live-mode retriesUp to 3 days, with exponential backoff
Sandbox retries3 over a few hours
Manual resend15 days from the Stripe Dashboard, 30 days with the Stripe CLI
OrderingNot guaranteed; dedupe on the event ID
ResponseA 2xx before any slow work

10 checks to run on your own tracking

CheckPass conditionIf it fails
1. Fresh Safari window, your partner linkA visitor cookie is set; read its expiry in the Storage tabA script-written cookie falls under the 7-day rule, so set it from the redirect and save the ID at signup
2. Google Chrome with uBlock Origin onThe cookie is still setA filter list matches your redirect or script host; serve it from your own domain
3. Landing address after the redirectThe ID is still in the URLA shortener or click wrapper dropped it; use a path slug
4. curl -I on the link1 hop, a 302, before the landing pageEach extra hop is another place to lose the ID
5. Stripe test card 4242 4242 4242 4242The Checkout Session shows the ID in client_reference_id or metadataThe field is missing, or a Payment Link dropped an invalid value
6. Event deliveries for that paymentA 200 within secondsThe endpoint is failing; see the retry rules above
7. Phone click, then laptop signup and payment with 1 emailThe sale reaches the partnerA cookie belongs to 1 browser, so match on the signup email
8. Refund the test paymentThe commission reversesRefunds are not reaching the ledger
9. Last 30 days of partner-referred chargesCount those carrying a visitor IDOrganic signups carry none, so judge only the referred set
10. Click counts from your 3 biggest partnersClose to your own logMore clicks on their side point upstream, at a blocked script or stripped parameter; equal clicks with missing sales point downstream, at the cookie, the payment field or the webhook

What TrackRev does for affiliate tracking

Each partner link is a server-side redirect on a TrackRev domain or a custom tracking domain with 1 CNAME record.

It logs the click, flags bots, sets the vid cookie for 365 days and passes the ID to your page as _vid. A pixel on your site tags Stripe Payment Links, Buy Buttons and pricing tables.

At payment it reads the ID from charge metadata, then the Checkout Session, then the customer's email if your site called trk.identify(email).

The pixel's cookie is written by JavaScript, so Safari's 7-day rule applies to it; the click log stays on the server.

One workspace-wide rule sets credit (last click, first click or shared). Each program sets its own cookie window and can hold commission for 0 to 180 days, with 0 the default.

Personal coupon codes credit partners who can't use links, and refunded or disputed charges take their commission back out.

PlanPriceAffiliate programCommission tracked a month
Free$0Locked; link tracking only, with 50 links and 1,000 events a monthNone
Starter$39 a monthUnlocked, 1 workspaceUp to $10K
Growth$99 a monthUnlocked, unlimited workspacesUp to $100K
Scale$199 a monthUnlocked, unlimited workspaces, priority supportUnlimited

From the pricing page. Annual billing pays for 9 months and gives 12.

Skip TrackRev if an affiliate network's contract makes its pixel the record for disputes. It reads revenue from Stripe, Polar, Lemon Squeezy and Paddle.

The 8-step build is in affiliate tracking without third-party cookies, and the affiliate program page covers links and payouts.

Found this useful? Share it.

PostLinkedIn

Frequently asked questions

Muzahid Maruf — Founder of TrackRev.io

Written by

Muzahid Maruf

Founder, TrackRev.io & Contant.io

Muzahid Maruf is the founder of TrackRev.io and Contant.io. He writes about marketing attribution, link tracking, and revenue analytics for SaaS teams.

Writes about Marketing attribution · Link tracking · Revenue analytics · SaaS growth

Stop guessing where your revenue comes from.

Set up TrackRev in about five minutes. The free plan covers 1,000 events a month, no card needed.

Start free