revbridge.js) is the browser counterpart to the Events API. It captures page views, sessions, and custom events from the client, manages an anonymous identity, and links anonymous history to a known profile when a visitor logs in — all through a single <script> tag.
Unlike the server-side Events API, the Web SDK runs in untrusted browser code, so it authenticates with a publishable key (rbpk_) that can only ingest events. See Key types.
Before you start
1
Get a publishable key
In the dashboard, open Settings → API Keys and copy your Publishable key (it starts with
rbpk_). This key is safe to embed in browser code: it can only send events, never read data or send messages.2
Add the SDK to your site
Paste the install snippet (below) into the
<head> of every page you want to track, before your own analytics code.3
Verify events arrive
Open your site, then check People or your event stream in the dashboard. A
page_view event should appear within a few seconds.
Events tagged
channel: web confirm the Web SDK is live.Install
Choose the script snippet for a no-build install, or the npm package for bundled apps. Both load the same SDK and expose the samerbd API.
Script tag (recommended)
Script tag (recommended)
Add this to your page The loader creates a
<head>. Replace rbpk_YOUR_WRITE_KEY with your publishable key from Settings → API Keys.window.rbd stub immediately, so you can call rbd.track(...) right away — calls are queued and replay once the SDK finishes loading. data-write-key auto-initializes the SDK; omit it if you prefer to call rbd.init() yourself.npm
npm
Configure
Pass options as the second argument toinit(writeKey, options). Every option is optional.
The SDK batches events and delivers them with
fetch (using keepalive on page exit), retries on 429 / 5xx, and coordinates across tabs so a batch is never sent twice.Track events
rbd.track(name, properties?) captures a custom event; rbd.page(properties?) captures a page_view (also sent automatically when autoPageview is on). Every event automatically carries channel: web, the session_id, and page context (page_url, page_path, page_title, referrer, and UTM parameters).
Identify users
Callrbd.identify(userId?, traits?) when a visitor logs in or gives you their identity. The anonymous ID stays stable, and every event from then on carries both the anon_id and the person identifiers you provide.
Anonymous to known linking
The first time a visitor identifies on a device, RevBridge adopts the anonymous profile: all of that visitor’s prior anonymous activity is re-pointed onto the now-known person, so you keep the full journey from first touch. This happens automatically for Web SDK traffic — you do not need to replay history or resend theanon_id alongside every identifier as you would server-side.
Adoption applies to Web SDK ingestion (events sent with a publishable key, which RevBridge tags as
source: web). If the device already belongs to a different known person, for example a previous login on a shared computer, it is not adopted — this protects shared devices. See Anonymous adoption for the full rules.Track commerce
Therbd.ecommerce.* helpers emit typed events that fill RevBridge’s native commerce columns (revenue, product IDs, order ID, and so on), so they power shopping segments and revenue attribution without custom mapping.
Manage consent
The SDK tracks a page-level consent state (pending / granted / denied) that gates what it collects, plus per-channel marketing consent on the profile.
Tracking consent. In opt-in mode nothing is written or sent until you call rbd.optIn(); events are buffered in memory meanwhile. rbd.optOut() stops tracking and clears stored data. The SDK also honors Global Privacy Control by default.
Channel consent. rbd.setConsent(update) records marketing opt-ins on the profile for segmentation:
Only explicit
true / false values are sent. An omitted channel stays “not informed”, which is distinct from an opt-out. See the consent flags model.API reference
Next steps
Key types
Publishable and secret keys, and where each one belongs.
User Identification
Merge keys and anonymous adoption in depth.
Event Types
Standard properties and the
web channel.Events API
The server-side counterpart for backend events.
