⌘K

How Affiliate Tracking Works

Understand how Revshare tracks affiliate referrals and attributes sales to the right affiliates.

Emil Klitmose

Written by Emil Klitmose

Updated recently

The Fundamentals of Affiliate Tracking

Affiliate tracking solves attribution: when someone purchases, which affiliate deserves credit? Tracking connects visitors to referral sources across days, devices, and touchpoints.

How tracking works:

  • Affiliate shares link with unique tracking code (e.g., yoursite.com/?ref=PARTNER123)
  • Customer clicks link → Tracking script captures affiliate code & stores cookie (30-90 day lifespan)
  • Customer browses → Cookie persists, remembering referral source
  • Customer purchases → System checks cookie, attributes sale to affiliate, commission credited

Common tracking URL formats:

  • URL parameter: yoursite.com?ref=PARTNER123
  • Subdomain: partner123.yoursite.com
  • Custom path: yoursite.com/partner123

Browser cookies store the affiliate identifier when a visitor clicks an affiliate link. This data persists in the browser, allowing your site to recognize them as an affiliate referral when they return to make a purchase.

Cookie duration impact:

  • 24h: Limited window, bad for affiliates (only impulse purchases, low-ticket items)
  • 30-60d: Standard window, most common, balanced approach, good for most products
  • 90d+: Long window, best for affiliates (high-ticket items, B2B software)

Cookie types:

  • First-party: Set by your own domain, works across all browsers, not blocked by default, privacy-friendly. Use this.
  • Third-party: Set by external domains, blocked by Safari/Firefox, being phased out, privacy concerns. Avoid this.

Cross-device challenge: Someone who clicks on mobile but purchases on laptop won't have the original cookie. Advanced systems use email matching and account-based tracking to solve this.

Attribution Models and Commission Logic

Attribution models determine which affiliate receives credit when multiple affiliates interact with the same customer.

Attribution models:

  • Last-click (most common): Most recent affiliate gets 100% commission. Simple, clear incentives. 90% of programs use this.
  • First-click: First affiliate gets 100% commission. Rewards discovery but ignores conversion drivers.
  • Linear: All affiliates share credit equally. Fair but complex, splits commissions.
  • Time-decay: More recent referrals get more credit. Balances contributions but complex to calculate.

Technical Implementation

JavaScript tracking scripts detect referral parameters and store affiliate identifiers. Scripts are lightweight, asynchronous, loaded via CDN. Server-side tracking stores referral info in database as backup—works even if cookies deleted or blocked. Payment provider integration matches transactions with affiliate identifiers via metadata or custom fields passed at checkout, returned in webhook notifications.

Cross-Domain and Subdomain Tracking

When marketing site (example.com) and checkout (app.example.com) are on different subdomains, use data-domain attribute to configure cookie scope. Setting data-domain="example.com" makes cookies accessible on both domains. For completely different domains, pass affiliate codes through URL parameters when linking between sites.

Common Tracking Challenges and Solutions

Challenges:

  • Ad blockers: 25-40% of users block tracking scripts. Solution: Use first-party subdomain tracking + server-side attribution
  • Cookie deletion: Safari auto-deletes after 7 days, users clear browsing data. Solution: Account-based tracking + email matching for logged-in users
  • Mobile apps: Don't use web cookies. Solution: Deep links + device fingerprinting + app-specific storage
  • Fraud: Cookie stuffing, fake clicks, last-click hijacking. Solution: Pattern detection (sales without clicks, impossible conversion rates)

Fraud detection red flags:

  • Many sales with zero clicks recorded
  • Conversion rates above 20% (suspicious)
  • Cookies set without referrer traffic
  • Sales from IPs in different countries than clicks

Privacy Regulations and Compliance

GDPR and CCPA regulate tracking. Provide clear privacy policies, use cookie consent banners (60-80% acceptance rates with well-designed flows). First-party data and server-side tracking are more privacy-friendly—track through your own systems, maintain data control, reduce privacy concerns. Server-side tracking can operate without cookies using session identifiers and database storage.

Ensuring Tracking Accuracy

Pre-launch testing checklist:

  • Click affiliate links & verify cookies are set (check browser dev tools)
  • Make test purchases & confirm attribution (verify affiliate receives credit)
  • Test across different browsers (Chrome, Safari, Firefox, Edge)
  • Test mobile devices (iOS Safari, Chrome mobile, in-app browsers)
  • Test with cleared cookies (click link → clear cookies → return → purchase)
  • Verify cross-domain tracking (if using subdomains or multiple domains)

Monitor metrics: clicks recorded, conversions attributed, unattributed sales (investigate if rising). When affiliates report missing commissions, investigate seriously—often reveals checkout flow issues, webhook failures, or edge cases. Implement backup tracking: server-side logging, email matching for accounts, manual review for disputes, database-backed attribution.

Build trust: When tracking fails, make it right. Manually credit legitimate sales. Your reputation for fair treatment attracts and retains top-performing affiliates.

Quick Tracking Summary

  • How tracking works: Affiliate shares link → Customer clicks → Cookie stored → Customer browses → Purchase → System checks cookie → Commission credited
  • Cookie duration: 24h (limited), 30-60d (standard), 90d+ (best for affiliates). Longer duration = more sales attributed
  • Cookie types: Use first-party cookies (set by your domain, work across browsers). Avoid third-party cookies (blocked by Safari/Firefox, being phased out)
  • Attribution models: Last-click (most common, 90% of programs), first-click, linear (equal share), time-decay (recent gets more credit)
  • Challenges: Ad blockers (25-40% of users), cookie deletion (Safari auto-deletes after 7 days), cross-device tracking, mobile apps, fraud
  • Solutions: First-party subdomain tracking, server-side attribution, account-based tracking, email matching, fraud detection patterns
  • Privacy compliance: GDPR and CCPA regulate tracking. Provide clear privacy policies, use cookie consent banners, prefer first-party data and server-side tracking
  • Testing: Verify cookies are set, test purchases, test across browsers/devices, verify cross-domain tracking, monitor unattributed sales

Ready to Scale Your SaaS?

Revshare is the easiest way to launch your own affiliate program. We take care of the technical stuff, so you can focus on growing your business.