How Attribution Works

Understanding how AffiliateBase tracks and attributes conversions to affiliates

Table of Contents

How Attribution Works

Attribution is the process of connecting a sale to the affiliate who referred the customer. Understanding how attribution works helps you configure your program and set fair expectations with affiliates.

The Attribution Flow

1. Visitor clicks affiliate link

2. Tracking script captures referral

3. Cookie stored in browser

4. Visitor browses, maybe leaves

5. Visitor returns, makes purchase

6. Referral ID passed to Stripe

7. Conversion attributed to affiliate

How Referrals Are Captured

When someone clicks an affiliate link like:

https://yoursite.com?via=affiliate-token

The tracking script:

  1. Detects the via parameter
  2. Validates the affiliate token
  3. Creates a referral record
  4. Stores data in cookies

Three cookies are set:

CookiePurposeAccessible
visitor_idUnique visitor trackingServer only
aff_{campaign}Campaign-specific trackingServer only
ab_referralReferral data for checkoutJavaScript

Step 3: Conversion Capture

When the visitor purchases:

  1. Your checkout reads window.affiliatebase_referral
  2. Passes it to Stripe as client_reference_id
  3. Stripe webhook notifies AffiliateBase
  4. Conversion matched to original referral
  5. Commission created for affiliate

Attribution Models

Last-Click Attribution (Default)

The last affiliate link clicked gets credit:

Day 1: Click Affiliate A's link
Day 3: Click Affiliate B's link
Day 5: Purchase
Result: Affiliate B gets credit

First-Click Attribution

Configure to credit the first affiliate instead:

Day 1: Click Affiliate A's link
Day 3: Click Affiliate B's link
Day 5: Purchase
Result: Affiliate A gets credit

Attribution Priority

When multiple attribution methods exist, priority order:

  1. Promo code (highest) - Customer entered affiliate’s code
  2. Referral cookie - Active referral from link click
  3. None - No attribution

This means if a customer clicks one affiliate’s link but uses another’s promo code, the promo code affiliate gets credit.

Attribution Window

The attribution window (cookie duration) determines how long after a click an affiliate can get credit:

WindowUse Case
7 daysShort sales cycles
30 daysStandard (default)
60 daysLonger consideration
90 daysHigh-ticket items

After the window expires, new clicks reset attribution. Existing referrals are frozen (no new conversions attributed).

Cross-Session Tracking

Same Device, Same Browser

Tracking works seamlessly:

  • Cookies persist across sessions
  • Referral maintained on return visits
  • No action needed

Different Browsers or Devices

Tracking has limitations:

  • Cookies are browser-specific
  • Phone → Desktop loses attribution
  • Incognito mode loses attribution

Workarounds

For better cross-device tracking:

  • Encourage customers to use same device
  • Use promo codes as backup
  • Capture email early for manual attribution

Referral States

Referrals progress through states:

StateDescription
VisitorClicked link, hasn’t converted
LeadTook qualifying action
ConversionMade a purchase
FrozenAttribution window expired

What Gets Tracked

Visitor Data

When a referral is created:

  • IP address (for fraud detection)
  • User agent (browser/device)
  • Referrer URL
  • Landing page
  • Timestamp

Conversion Data

When purchase completes:

  • Order amount
  • Product purchased
  • Customer email
  • Payment status

Attribution Troubleshooting

Conversion Not Attributed

Common causes:

  1. Cookie expired (outside attribution window)
  2. Different browser/device used
  3. client_reference_id not passed to Stripe
  4. Tracking script not on checkout pages

Wrong Affiliate Credited

Check:

  1. Which affiliate’s link was clicked last
  2. Was a promo code used?
  3. Cookie value at time of purchase
  4. Attribution window timing

Best Practices

For Accurate Attribution

  1. Install script on all pages - Not just landing pages
  2. Pass referral to checkout - Always include client_reference_id
  3. Use promo codes as backup - For offline/cross-device
  4. Set appropriate window - Match your sales cycle

For Fair Attribution

  1. Communicate clearly - Explain how attribution works
  2. Set reasonable windows - Not too short, not too long
  3. Be consistent - Same rules for all affiliates
  4. Handle disputes fairly - Have a clear process

Technical Details

How Cookies Work

// Reading the referral cookie
const referralId = window.affiliatebase_referral;

// The cookie contains:
{
  referral_id: "abc123",
  affiliate_id: "def456",
  campaign_id: "ghi789",
  expires: "2024-02-15T00:00:00Z"
}

How Stripe Integration Works

// Checkout session with attribution
const session = await stripe.checkout.sessions.create({
  // ... other options
  client_reference_id: referralId, // This connects the sale to the referral
});

Next Steps