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 does an affiliate link mean?
  2. 02How does affiliate tracking work, from click to commission?
  3. 03What are the 4 ways to track a referral?
  4. 04Which partner gets the credit when several links touch one buyer?
  5. 05How do you use an affiliate link as a partner?
  6. 06Where does affiliate tracking break?
  7. 07Which 10 checks should you run on your own tracking?
  8. 08What does TrackRev do for affiliate tracking?

Explore with AI

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

Affiliate tracking is the process of recording which partner's link a customer clicked and crediting 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 carries the visitor ID in a Checkout Session reference field or in metadata. With neither, the webhook has no click 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, updated October 15, 2025, requires.

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

An affiliate link therefore has 3 jobs: carry the partner ID, deliver the visitor to the merchant's page, and leave a record the payment can find.

A link that does the first two jobs but not the third produces clicks and no commission. 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 does affiliate tracking work, from click to commission?

Affiliate tracking is a chain of 6 handoffs between a partner's link and a Stripe payment. First, a redirect on the merchant's domain logs the click. Second, the server sets a visitor ID cookie.

Third, signup saves the ID beside the email. Fourth, payment creation writes the ID onto the Stripe Checkout Session. Fifth, Stripe sends a webhook for each paid invoice. Finally, a matching job finds the click and applies the credit rule.

A break at any handoff files the sale under direct, which is why the 10 checks later in the post test each handoff in turn.

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

What happens when a referral pays on day 41?

A late referral is a sale that pays long after the click, and day 41 shows the risk. 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.

Months the customer staysRevenue at $49Jane's commission at 30%
1$49$14.70
3$147$44.10
6$294$88.20
12$588$176.40

Illustrative figures for the day-41 customer. The ID decides whether every row is credited or none.

Cookie windowCloses relative to the day-41 paymentFirst commission at 30%
30 days11 days before$0, filed as direct
45 days4 days after$14.70
60 days19 days after$14.70
90 days49 days after$14.70

Same $49 sale, four window settings. Only the first setting loses the credit.

What are the 4 ways to track a referral?

A tracking method is the key used to match a payment to a partner.

Link and cookie matches on a visitor ID, coupon code on a personal code, postback on a network click ID, and email match on the address saved at signup.

Link and cookie is the default for SaaS because the buyer takes no extra step. Coupon codes cover audio and print, where nothing can be clicked. Postback suits partners who bring a network.

For example, a podcast host with no link to click can still earn through a personal code typed at checkout.

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

A credit rule is the policy that picks one partner, or splits the commission, when several links touch one buyer.

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, which is $14.70 in total.

The table shows 3 rules and 3 outcomes, and the attribution models comparison has the trade-offs. Because all three rules pay out the same $14.70, the choice moves money between partners, never between the partners and the merchant.

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
Plan priceMonthly commission at 30%12-month commission at 30%
$19$5.70$68.40
$49$14.70$176.40
$99$29.70$356.40
$199$59.70$716.40

What one lost visitor ID costs at four plan prices, assuming the customer stays 12 months.

Using an affiliate link means sharing the exact address the partner dashboard issues. First, use the link exactly as issued, since a shortener or an edited ID can drop the ID.

Second, check in a private window that the landing address still carries the ID. Third, disclose the commission. The Federal Trade Commission's Endorsement Guides Q&A suggests wording such as "I get commissions for purchases made through links in this post".

Audio and print need a different path, so a personal coupon code covers those formats. Under the Endorsement Guides the commission should be disclosed close to the recommendation, and "affiliate link" alone may not be understood; see the compliance guide.

Where does affiliate tracking break?

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

A browser rule is a setting that limits how long a cookie lives or whether it travels across sites. Four rules matter for partner cookies, listed in the table with the version that introduced each one.

The Safari ITP post covers the Safari rules in depth.

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

Why do cookies 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, listed in the table with the limit on each. A cookie is scoped to a host, and a hosted checkout is a different host, so the checkout never sees the cookie.

The same failure appears with a Stripe Payment Link, because the link opens on a Stripe domain.

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.

Why do windows shorter than the sales cycle lose sales?

A cookie window shorter than the sales cycle is the most common cause of lost credit, because the window closes before the buyer pays. In our program setup the window starts at 60 days and accepts 1 to 3,650.

Choose yours from data. First, pull the last 100 paying customers. Second, compute the days from first partner click to first payment. Third, 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.

Jane's day-41 payment in the earlier example shows the cost: a 30-day window loses $176.40 over 12 months.

How do webhooks handle 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.

A webhook is an HTTP call from Stripe to the merchant's server after each event.

The merchant's endpoint must answer with a 2xx status quickly, then do slow work afterward, because Stripe retries a failed delivery for up to 3 days in live mode.

Events can arrive out of order, so dedupe on the event ID.

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

Which 10 checks should you run on your own tracking?

A tracking audit is a set of tests that follow one test visitor from the partner link to the ledger. The 10 checks run in order.

Checks 1 to 4 cover the click and the redirect, checks 5 and 6 cover the Stripe payment and the webhook, check 7 covers a visitor who switches devices, check 8 covers a refund, and checks 9 and 10 compare totals against the data you already hold.

Run all 10 after any change to the redirect, the checkout or the pixel.

Check 5 uses Stripe test card 4242 4242 4242 4242, and check 4 uses curl -I to count redirect hops, where 1 hop is the pass condition.

Two browsers cover the most common blockers, and bot traffic filtering keeps crawler clicks out of the counts.

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 does TrackRev do for affiliate tracking?

TrackRev is SaaS affiliate software for indie hackers and small SaaS teams. Each partner link in the redirect we built is a server-side redirect on a TrackRev domain or a custom tracking domain with 1 CNAME record.

The redirect 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 the pixel 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 the pixel cookie, while 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 hold, from 0 to 180 days. Personal coupon codes credit partners who cannot use links.

SettingValue in TrackRev
Visitor cookie lifetime365 days, set by the redirect
Cookie window per program60 days by default, 1 to 3,650 allowed
Hold on new commission0 to 180 days, default 0
Revenue processors6 billing systems
Credit rules3: last click, first click, shared

Tracking settings described in this section.

PlanPriceAffiliate programCommission tracked
Free$0Locked; link tracking only, with 50 links and 1,000 events a monthNone
Indie$29 a monthUnlocked, 1 workspace and 1 tracked domain, soloNo cap
Growth$299 a yearUnlocked, up to 10 workspaces and 10 tracked domains, unlimited team membersNo cap

From the pricing page. Indie bills monthly and Growth bills yearly.

Skip TrackRev if an affiliate network's contract makes its pixel the record for disputes.

TrackRev reads revenue from Stripe, Paddle Billing, Polar, Lemon Squeezy, Creem and Dodo Payments, with no limit on tracked revenue and 0% fees on it, as our own pricing page states.

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 founded TrackRev.io, SaaS affiliate software with no limit on tracked revenue, and Contant.io. He writes about affiliate programs.

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

Run your affiliate program without a revenue cap.

Affiliate software for indie hackers and small SaaS teams: $29 a month flat, 0% fees, link tracking and revenue attribution built in. Free to start, no card.