Web SDK
The Web SDK is the @signal-sparrow/sdk package used by React, Vue, and plain JavaScript sites. If you installed the HTML snippet instead, the exact same methods are available on the global window.rp object.
Setup
Install the package:
npm install @signal-sparrow/sdk
Then initialize it once, as early as possible. Settings → Tracking generates this call with your public key and endpoint already filled in:
import { init } from '@signal-sparrow/sdk';
init('pk_live_YOUR_PUBLIC_KEY', {
endpoint: 'https://YOUR_TRACKING_DOMAIN/e/YOUR_COLLECT_TOKEN',
});
endpoint outside the HTML snippetThe default is the relative path /collect, which resolves against your own site. In a bundled app that means events go to your server instead of ours and are silently lost. The HTML snippet is exempt: it is served from your tracking domain, so the relative path already resolves back to us.
Using the HTML snippet? Initialization is already handled for you — skip straight to the methods below via window.rp.
Configuration options
init accepts an optional second argument:
init('pk_live_YOUR_PUBLIC_KEY', {
endpoint: 'https://YOUR_TRACKING_DOMAIN/e/YOUR_COLLECT_TOKEN',
consentMode: 'anonymous',
autoCapture: true,
debug: false,
});
| Option | Type | Default | What it does |
|---|---|---|---|
endpoint | string | /collect | Where events are sent. Copy the full URL from Settings → Tracking — see the warning above. |
consentMode | 'anonymous' | 'hold' | 'anonymous' | How the SDK behaves before a visitor consents. See Consent & Privacy Modes. |
autoCapture | boolean | object | true | Automatic browser capture: scroll depth, engaged time, outbound clicks and form-based identify. Pass false to turn it all off, or an object to toggle individual features. |
debug | boolean | false | Print helpful messages to the browser console while testing. |
Methods
identify(email)
Links the current visitor to a known person, usually right after signup or login. This is the single most important call for accuracy.
import { identify } from '@signal-sparrow/sdk';
identify('user@example.com');
The email is scrambled (hashed) before it leaves the browser. Full details in Identifying Users.
track(eventName, properties?)
Optionally record a custom action from your site, such as a demo request.
import { track } from '@signal-sparrow/sdk';
track('Demo Requested', { plan: 'growth' });
track for revenueYour paying-customer events (subscriptions, upgrades, and so on) come straight from Stripe automatically. Use track only for extra front-end actions you want to measure.
setConsent(granted)
Releases tracking when you're using consentMode: 'hold' — call it with true once the visitor accepts your cookie banner, or false if they decline.
import { setConsent } from '@signal-sparrow/sdk';
setConsent(true);
Using the global object
With the HTML snippet, call the same methods on window.rp:
<script>
if (window.rp) {
rp.identify('user@example.com');
}
</script>
Next
- Next.js SDK — the
@signal-sparrow/nextpackage - Identifying Users — the one call that drives your match rate