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
- 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 */ });Cookie consent (UK and EU)
Under UK PECR and the EU ePrivacy rules, an affiliate referral cookie needs the visitor's consent. If your site waits for consent before tracking, use cookieless mode for visitors who haven't accepted, so partners still get credit:
<script defer src="https://partli.app/partli.js?v=6" data-partli data-partli-cookieless></script>Use the versioned URL
partli.js?v=6 to make sure no browser or CDN serves a cached older version. You can check in the console: Partli.version should be "6" or higher.In cookieless mode partli.js reads and writes no cookies, localStorage or sessionStorage. The referral click is still recorded, the click id and partner coupon are kept in memory, and links to other pages on your site carry them forward in the URL (?partli_cid=), so a checkout later in the same visit is attributed. The only thing lost is a visitor who leaves and comes back days later to buy.
When the visitor accepts cookies, switch to normal storage; if they withdraw consent, switch back:
// on Accept
window.Partli?.enableStorage(); // saves the click to the pref_cid cookie
// on withdrawal
window.Partli?.disableStorage(); // deletes the cookies, keeps the click in memoryYou can also set window.PartliConfig = { cookieless: true } before the script loads instead of the attribute. Partli.isCookieless() tells you the current mode.
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.