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:

  1. Sends a POST to /track/click with the referral code
  2. Receives a referral_id (UUID)
  3. Sets a first-party cookie: mfbl_ref=UUID
  4. Stores in localStorage as Safari ITP fallback
  5. Sets window._mfbl = { referral: UUID }

2. Stripe Auto-Detection

After DOM ready + 2s, t.js scans for Stripe elements and injects the referral ID:

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

  1. localStorage fallback: Automatic — not subject to ITP cookie limits
  2. Server-side proxy: Route tracking through your own domain for server-set cookies
  3. Coupon codes: Always work regardless of cookie state