SDK reference
Every public method on the analytics global, plus the data-track attribute.
The browser SDK is loaded by the install snippet. It exposes a single global, window.analytics, with three methods. The API is frozen — we won't add, remove, or rename methods in V1.
Call the SDK as window.analytics?.success(...). The optional chaining (?.) keeps your code safe if an ad blocker stops the script from loading — the call is skipped instead of throwing. See TypeScript below if your build flags analytics as an unknown name.
analytics.pageview()
Manually fire a pageview. The SDK calls this automatically on page load and on history.pushState / popstate, so single-page apps don't need to call it. Only call it manually if you're using a router that the SDK can't hook into.
window.analytics?.pageview()analytics.success(name, properties?)
Fire a success event. The name is the rule name you registered in the dashboard. properties is an optional flat object of string/number/boolean values.
window.analytics?.success('paid-customer', {
plan: 'starter',
value: 9.99,
})Where to call it
Call it after the conversion is confirmed — usually inside the function that handles the action:
async function handleSignup() {
await createAccount() // your signup logic
window.analytics?.success('signup')
}To fire it on a click, wrap it in an arrow function so you pass a handler instead of calling it during render:
<button onClick={() => window.analytics?.success('signup')}>
Get started
</button>Don't write onClick={window.analytics?.success('signup')}. That calls success on every render and won't type-check — the call returns void, not an event handler (Type 'void' is not assignable to type 'MouseEventHandler'). The () => wrapper is what makes it a handler.
PII safety
Any property key matching email, phone, password, or ssn (case-insensitive) is stripped server-side before the event is written. You can't accidentally leak PII even if you forget.
Server clock
The timestamp on the row is set by the server, not the browser. Your client's clock skew, timezone, and time-tampering don't affect data quality.
analytics.identify(userId)
Associate the current visitor with a stable user identifier for v1.1's cross-session journey attribution. Today this just tags the next events with success_user_id. Behavior won't change.
window.analytics?.identify('user_42')TypeScript
window.analytics is attached at runtime by the install script, so a TypeScript project doesn't know about it — tsc will fail with Property 'analytics' does not exist on type 'Window'. Declare the global once (for example in a global.d.ts at your project root) and the calls above type-check everywhere:
declare global {
interface Window {
analytics?: {
success(name: string, opts?: {
value?: number
userId?: string
properties?: Record<string, string | number | boolean>
}): void
pageview(path?: string): void
identify(userId: string): void
}
}
}
export {}The export {} keeps the file a module so the declare global augments the global scope rather than redefining it.
data-track="..." attribute
Add data-track to any clickable element. The SDK auto-attaches a delegated click listener that fires a click event with the attribute value as name.
<button data-track="signup-cta">Get started</button>
<a data-track="pricing-nav" href="/pricing">Pricing</a>The click row is independent of any success rule. Register a click rule in the dashboard to synthesize a success event when the click happens.
SDK options
There are no SDK options for V1. Everything you'd configure (success rules, sites, API keys) is configured server-side in the dashboard.
What's next
- For backend-confirmed conversions: Server events.
- For ad-blocker resilience: First-party proxy setup.
- For a security review + CSP directives: Security & CSP.