JavaScript snippet (partli.js)
One <script> tag — captures partner referrals from URLs and auto-binds them to Stripe Checkout.
Install
Drop this anywhere inside your site's <head>:
<script defer src="https://partli.app/partli.js" data-partli></script>That's the entire install. Nothing else to configure.
What it does
- Captures referrals from your URLs. Whenever a visitor lands on your site with
?via=<slug>(or?ref=or?partli=), the script POSTs to our click endpoint, sets thepref_cidcookie (90 days), and strips the param from the URL. - Auto-binds to Stripe Checkout. Wraps
Stripe.redirectToCheckout()and any<a href="https://buy.stripe.com/...">Payment Link on the page. When a referred visitor checks out, we automatically inject the click ID asclient_reference_idso the conversion is attributable. - Exposes
window.Partlifor advanced use:getClickId(),captureFromUrl(),attachToStripeSession(opts).
Snippet alone is not enough for sale tracking
The snippet handles the merchant-facing click capture and stamps your Stripe Checkout with the right metadata, but Partli still needs to learn when the checkout completes. Pair the snippet with one of these:
- Connect your Stripe via OAuth — recommended, no code.
- Webhook handler — POST sales to our REST API from your backend.
Compatible checkout flows
The snippet auto-binds these out of the box:
- Stripe.js + redirectToCheckout — wraps the call.
- Stripe Payment Links (
buy.stripe.com/...) — appends?client_reference_id=on click. - Embedded Checkout / Stripe Elements — pass
window.Partli.getClickId()as theclientReferenceIdwhen you create the session.
Custom flow (Embedded Checkout / Elements)
// On your backend when creating the Stripe Checkout Session:
const clickId = req.headers['x-partli-click-id']; // or send via fetch body
const session = await stripe.checkout.sessions.create({
mode: 'subscription',
line_items: [...],
client_reference_id: clickId, // <- the magic line
success_url: '...',
cancel_url: '...',
});Manual API
If you need to read or set the click ID from your own JavaScript:
// Read current click attribution (returns null if no referrer)
const clickId = window.Partli.getClickId();
// Force-capture from URL (returns Promise<clickId|null>)
window.Partli.captureFromUrl();
// Add the click ID to a Stripe session opts object
const opts = window.Partli.attachToStripeSession({ /* your opts */ });Security & privacy
- The script makes a single POST to
partli.app/api/track/clickper page load that has a?via=param. No analytics, no fingerprinting, no other beacons. - The cookie is first-party on your domain (set by JS),
SameSite=Lax, secure on HTTPS. - The script is <3KB minified, served with long cache headers.