Tracking Script (t.js)
Installation
<script async src="https://cdn.partner-forge.com/t.js"
data-account="YOUR_ACCOUNT_ID"></script>
How It Works
1. Click Detection
When a visitor arrives with a tracking parameter (?ref=, ?via=, ?referral=, ?aff=), t.js:
- Sends a POST to
/track/clickwith the referral code - Receives a
referral_id(UUID) - Sets a first-party cookie:
mfbl_ref=UUID - Stores in
localStorageas Safari ITP fallback - Sets
window._mfbl = { referral: UUID }
2. Stripe Auto-Detection
After DOM ready + 2s, t.js scans for Stripe elements and injects the referral ID:
- Payment Links: Appends
?client_reference_id=UUID - Pricing Tables: Sets
client-reference-idattribute - Checkout forms: Injects hidden input
3. Server-Side Integration
For custom Stripe Checkout sessions, read the cookie server-side:
const referral = req.cookies.mfbl_ref;
const session = await stripe.checkout.sessions.create({
client_reference_id: referral || undefined,
// ... other params
});
Coupon Code Attribution
For zero-code tracking, use Stripe Promotion Codes with affiliate metadata. No cookies needed.
Safari ITP Mitigation
- localStorage fallback: Automatic — not subject to ITP cookie limits
- Server-side proxy: Route tracking through your own domain for server-set cookies
- Coupon codes: Always work regardless of cookie state