Install + identify
The SDK does three things: track page loads (which capture ?ref= and refresh the cookie),
identify users when they sign up or log in, and emit revenue events.
Install
npm
npm install @openpartner/sdkimport { OpenPartner } from '@openpartner/sdk';
export const op = new OpenPartner({ siteId: 'site_xxx', // optional: override the router URL for self-hosted deploys routerUrl: 'https://r.yourdomain.com',});CDN
<script src="https://cdn.openpartner.dev/sdk/v1.js"></script><script> window.openpartner.init({ siteId: 'site_xxx' });</script>Track
Call once on every page load. It reads ?ref= from the URL, drops or refreshes the
first-party cookie, and is safe to call multiple times.
op.track();Identify
Call when a user signs up or logs in. This is what stitches an authenticated user to the click that brought them in — enabling cross-device attribution and ITP-resilience on Safari.
op.identify(user.id, { email: user.email, // any traits you want to expose to the partner dashboard});You can call identify() multiple times — the same user always maps to the same Identity row,
and additional traits are merged.
Anonymous tracking
If you don’t want to expose userIds, you can identify with a hash:
op.identify(sha256(user.email + SITE_SALT));The attribution chain still works because the same hash is reproducible across sessions.