Cross-Domain Tracking
When your customer journey spans multiple domains, special configuration ensures affiliate tracking continues seamlessly. This guide covers common scenarios and solutions.
Common Scenarios
Subdomain Checkout
Marketing: yoursite.com
Checkout: checkout.yoursite.com
App: app.yoursite.com
Third-Party Checkout
Your site: yoursite.com
Stripe hosted: checkout.stripe.com
Multiple Domains
Main brand: mainbrand.com
Product site: product.com
Subdomain Tracking
How It Works
Cookies can be shared across subdomains when set correctly. AffiliateBase automatically configures cookies for subdomain sharing.
Automatic Configuration
The tracking script sets cookies at the root domain:
.yoursite.com → works on:
- yoursite.com
- www.yoursite.com
- checkout.yoursite.com
- app.yoursite.com
Setup Requirements
- Install tracking script on all subdomains
- Use the same organization ID
- Cookies will be shared automatically
Verification
Test by:
- Click affiliate link on
yoursite.com - Navigate to
checkout.yoursite.com - Check
window.affiliatebase_referralstill exists
Third-Party Checkout Pages
The Challenge
When checkout happens on a different domain (like checkout.stripe.com), cookies don’t transfer. The referral must be passed explicitly.
Solution: client_reference_id
Pass the referral ID to Stripe before redirecting:
// Before redirecting to Stripe
const referralId = window.affiliatebase_referral;
const session = await stripe.checkout.sessions.create({
// ... other options
client_reference_id: referralId,
});
// User redirects to checkout.stripe.com
// Referral is passed via the session, not cookies
Payment Links
For Stripe Payment Links, the tracking script automatically appends the referral:
Original: https://buy.stripe.com/xxxxx
Modified: https://buy.stripe.com/xxxxx?client_reference_id=referral-id
No additional configuration needed if the tracking script is installed.
Multiple Domains
Different Root Domains
Tracking doesn’t automatically work across different root domains:
mainbrand.com → product.com (cookies don't transfer)
Solution Options
Option 1: Pass referral in URL
When linking between domains, include the referral:
const referralId = window.affiliatebase_referral;
const targetUrl = `https://product.com?referral=${referralId}`;
Option 2: Use promo codes
Promo codes work regardless of domain:
Customer uses code "JOHN20" on product.com
→ Attributed to affiliate John
Option 3: Server-side tracking
Store referral server-side (in session/database) and retrieve on the other domain.
Handling Redirects
Preserving Parameters Through Redirects
If your site uses redirects, ensure tracking parameters are preserved:
Incoming: yoursite.com/?via=john
Redirect: yoursite.com/welcome?via=john ✓ Good
Redirect: yoursite.com/welcome ✗ Lost tracking
Common Redirect Issues
- Marketing redirects stripping parameters
- CMS/plugin redirects not preserving query strings
- HTTPS upgrades dropping parameters
Single Page Applications (SPAs)
Client-Side Navigation
For SPAs, tracking must handle route changes:
// The script handles initial load
// For subsequent navigation, referral persists in cookies
// If manually navigating with a new referral:
window.history.pushState({}, '', '/?via=newaffiliate');
// Script will detect and update
React/Next.js/Vue
The tracking script works with SPAs:
- Install script in your app shell
- Initial page load captures referral
- Subsequent navigation maintains cookies
Testing Cross-Domain
Subdomain Test
- Set up tracking on both subdomains
- Click affiliate link on subdomain A
- Navigate to subdomain B
- Verify
window.affiliatebase_referralexists
Different Domain Test
- Click affiliate link on domain A
- Manually pass referral to domain B
- Verify referral is captured on domain B
Limitations
What Doesn’t Work
- Different browsers: Referral won’t transfer
- Different devices: Referral won’t transfer
- Incognito/Private mode: Cookies may not persist
- Cookie blocking: Some browsers block third-party cookies
Workarounds
For challenging scenarios:
- Use promo codes as universal backup
- Capture email early for manual attribution
- Encourage customers to complete journey in one session
Best Practices
For Multi-Domain Setups
- Single source of truth: One domain captures initial referral
- Explicit passing: Always pass referral ID between domains
- Fallback methods: Use promo codes as backup
- Test thoroughly: Verify all paths work
For Subdomain Setups
- Consistent script: Same tracking script everywhere
- Same organization: Use same org ID across subdomains
- Test cookies: Verify cookies accessible on all subdomains
Troubleshooting
Referral Lost Between Subdomains
- Check cookie domain is set to root
- Verify both subdomains have script installed
- Check for cookie blocking in browser
- Look for CORS or security issues
Referral Lost at Checkout
- Verify
client_reference_idis passed to Stripe - Check referral existed before redirect
- Test in non-incognito browser
- Review Stripe session data
Next Steps
- Learn about attribution windows
- Set up conversion tracking
- Configure coupon tracking as backup