Skip to main content
The Web SDK (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 same rbd API.
Only use a publishable rbpk_ key in browser code. Never embed a secret rbk_ / rbak_ key — those carry full account permissions. See Key types.

Configure

Pass options as the second argument to init(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

Call rbd.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 the anon_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.
On shared devices, call rbd.reset() on logout. This rotates the anonymous ID and clears stored identifiers, so the next visitor starts a fresh anonymous profile.

Track commerce

The rbd.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.
On Shopify storefronts, set ecommerce.trackPurchase: false in init() — purchases already arrive through the server-side Shopify sync, and the SDK still captures the browsing funnel (product_view → add_to_cart → checkout_started). Pass the Shopify customer ID as the userId in identify() to unify web and store activity.
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.