Tracker Analytics SDK
Analytics SDK
Section titled Analytics SDKLearn how to set up the OpenReplay tracker analytics SDK.
Enabling the SDK
Section titled Enabling the SDKThe analytics SDK is opt-in. It is only instantiated when you pass analytics.active to the tracker constructor — until then tracker.analytics is null and tracker.track() is a no-op.
import Tracker from '@openreplay/tracker'
const tracker = new Tracker({
projectKey: "YOUR_PROJECT_KEY",
analytics: { active: true },
})
tracker.start()
Options
Section titled Optionsactive: booleanTurns the analytics SDK on. Default:false.ingestPoint?: stringEndpoint analytics batches are sent to. Self-hosted deployments only — on OpenReplay Cloud this is ignored andhttps://api.openreplay.com/ingestis used. Defaults to the tracker’singestPoint.
Modules
Section titled ModulesTo learn more about managing your analytics data in the OpenReplay UI, visit Data Management.
Top-level signatures
Section titled Top-level signatures// Identify a user with an id (e.g. email, username, etc.)
tracker.analytics.identify(userId: string): void
// same as
tracker.analytics.people.identify(userId)
// Add event to batch with option to send it immediately
tracker.analytics.track(eventName: string, tempProperties?: Record<string, any>, options?: { send_immediately: boolean })
// same as
tracker.analytics.events.track(eventName, tempProperties, options)
// Clear user id, people properties and super properties, and stop the batcher
tracker.analytics.reset(): void
Tracker-level shorthands
Section titled Tracker-level shorthandsThese live on the tracker itself, so they are safe to call without reaching into tracker.analytics (they are no-ops while analytics is disabled):
// Same as tracker.analytics.track(...)
tracker.track(eventName: string, properties?: Record<string, any>, options?: { send_immediately: boolean })
// Sets the replay's user ID *and* calls analytics.people.identify() with it
tracker.setUserID(id: string): void
tracker.identify(id: string): void // alias of setUserID
// Send analytics events under your own token, without session recording
tracker.setAnalyticsToken(token: string): void
reset
Section titled resetClears the identified user (including the persistent device id), all people properties, all super properties, and stops the batcher. Call it on logout.
tracker.analytics.reset()
Have questions?
Section titled Have questions?If you encounter any issues, connect to our Slack or check out our Forum and get help from our community.