Reference
Every public method of @screeb/sdk-browser, with its signature.
Complete reference for @screeb/sdk-browser. New to Screeb? Start with the install guide.
Methods by capability
Section titled “Methods by capability”Lifecycle
Section titled “Lifecycle”| Method | Description | More |
|---|---|---|
init(websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string, spaNavigationHandler?: SpaNavigationHandler) |
Initializes Screeb tag. | Guide |
load(options?: ScreebOptions) |
Appends Screeb tag into your dom. | Guide |
close() |
Shutdowns current Screeb session. | Guide |
Identity
Section titled “Identity”| Method | Description | More |
|---|---|---|
identity(userId: string, userProperties?: PropertyRecord) |
Change the current user identity. | Guide |
identityProperties(userProperties: PropertyRecord) |
Adds properties to the current user identity. | Guide |
identityReset() |
Resets the current user identity. | Guide |
setAnonymousId(anonymousId: string) |
Tells Screeb which anonymous id your CDP already uses for the current visitor (Amplitude device id, Segment or RudderStack anonymous id). | Guide |
identityGet(): Promise<ScreebIdentityGetReturn> |
Retrieves the current user identity. | Guide |
Groups
Section titled “Groups”| Method | Description | More |
|---|---|---|
identityGroupAssign(groupName: string, groupType?: string, groupProperties?: PropertyRecord) |
Assigns the current user to a group. | Guide |
identityGroupUnassign(groupName: string, groupType?: string) |
Unassigns the current user to a group. | Guide |
Tracking
Section titled “Tracking”| Method | Description | More |
|---|---|---|
eventTrack(eventName: string, eventProperties?: PropertyRecord) |
Tracks a user event. | Guide |
Surveys
Section titled “Surveys”| Method | Description | More |
|---|---|---|
surveyStart(surveyId: string, distributionId?: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksSurveyStart, language?: string, selectors?: string | string[]) |
Starts a survey by its ID. | Guide |
surveyClose() |
Interrupts a running survey. | Guide |
Messages
Section titled “Messages”| Method | Description | More |
|---|---|---|
messageStart(messageId: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksMessageStart, language?: string) |
Starts a message by its ID. | Guide |
messageClose() |
Interrupts a running message. | Guide |
Session replay
Section titled “Session replay”| Method | Description | More |
|---|---|---|
sessionReplayStart() |
Starts a session replay. | Guide |
sessionReplayStop() |
Interrupts a running session replay. | Guide |
| Method | Description | More |
|---|---|---|
debug() |
Prints the actual state information of Screeb tag. | Guide |
targetingDebug() |
Prints the current state of the targeting engine. | Guide |
isLoaded() |
Checks if Screeb tag has been loaded. | Guide |
Privacy helpers
Section titled “Privacy helpers”| Method | Description | More |
|---|---|---|
ScreebMaskText<T extends Element>(element: T): T |
Marks an element as sensitive in Screeb session replay. | Guide |
ScreebNoCapture<T extends Element>(element: T): T |
Excludes an element from Screeb session replay capture. | Guide |
ScreebId<T extends Element>(element: T, id: string): T |
Sets a stable Screeb element ID for IAM targeting and replay context. | Guide |
API signatures
Section titled “API signatures”Lifecycle
Section titled “Lifecycle”export function init(websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string, spaNavigationHandler?: SpaNavigationHandler);export function load(options?: ScreebOptions);export function close();Identity
Section titled “Identity”export function identity(userId: string, userProperties?: PropertyRecord);export function identityProperties(userProperties: PropertyRecord);export function identityReset();export function setAnonymousId(anonymousId: string);export function identityGet(): Promise<ScreebIdentityGetReturn>;Groups
Section titled “Groups”export function identityGroupAssign(groupName: string, groupType?: string, groupProperties?: PropertyRecord);export function identityGroupUnassign(groupName: string, groupType?: string);Tracking
Section titled “Tracking”export function eventTrack(eventName: string, eventProperties?: PropertyRecord);Surveys
Section titled “Surveys”export function surveyStart(surveyId: string, distributionId?: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksSurveyStart, language?: string, selectors?: string | string[]);export function surveyClose();Messages
Section titled “Messages”export function messageStart(messageId: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksMessageStart, language?: string);export function messageClose();Session replay
Section titled “Session replay”export function sessionReplayStart();export function sessionReplayStop();export function debug();export function targetingDebug();export function isLoaded();Privacy helpers
Section titled “Privacy helpers”export function ScreebMaskText<T extends Element>(element: T): T;export function ScreebNoCapture<T extends Element>(element: T): T;export function ScreebId<T extends Element>(element: T, id: string): T;HookOnReady
Section titled “HookOnReady”type HookOnReady = (data: { channel: Channel; user: User }) => void;HookOnSurveyDisplayAllowed
Section titled “HookOnSurveyDisplayAllowed”type HookOnSurveyDisplayAllowed = ( data: HookCommonPropertiesSurvey,) => boolean;HookOnMessageDisplayAllowed
Section titled “HookOnMessageDisplayAllowed”type HookOnMessageDisplayAllowed = ( data: HookCommonPropertiesSurvey,) => boolean;HookOnSurveyShowed
Section titled “HookOnSurveyShowed”type HookOnSurveyShowed = ( data: HookCommonPropertiesSurvey & { response: { id: string; items: ResponseItem[]; }; },) => void;HookOnSurveyStarted
Section titled “HookOnSurveyStarted”type HookOnSurveyStarted = ( data: HookCommonPropertiesSurvey & { response: { id: string; }; },) => void;HookOnSurveyCompleted
Section titled “HookOnSurveyCompleted”type HookOnSurveyCompleted = ( data: HookCommonPropertiesSurvey & { response: { id: string; items: ResponseItem[]; }; },) => void;HookOnSurveyHidden
Section titled “HookOnSurveyHidden”type HookOnSurveyHidden = ( data: HookCommonPropertiesSurvey & { response: { id: string; items: ResponseItem[]; hide_reason: ResponseStatus; }; },) => void;HookOnMessageShowed
Section titled “HookOnMessageShowed”type HookOnMessageShowed = ( data: HookCommonPropertiesMessage & { response: { id: string; items: ResponseItem[]; }; },) => void;HookOnMessageStarted
Section titled “HookOnMessageStarted”type HookOnMessageStarted = ( data: HookCommonPropertiesMessage & { response: { id: string; }; },) => void;HookOnMessageCompleted
Section titled “HookOnMessageCompleted”type HookOnMessageCompleted = ( data: HookCommonPropertiesMessage & { response: { id: string; items: ResponseItem[]; }; },) => void;HookOnMessageHidden
Section titled “HookOnMessageHidden”type HookOnMessageHidden = ( data: HookCommonPropertiesMessage & { response: { id: string; items: ResponseItem[]; hide_reason: ResponseStatus; }; },) => void;HookOnQuestionReplied
Section titled “HookOnQuestionReplied”type HookOnQuestionReplied = ( data: HookCommonPropertiesSurvey & { response: { id: string; status: null; question: ResponseItemQuestion; answer: ResponseItemAnswer; items: ResponseItem[]; }; },) => void;HookOnButtonNavigateStarted
Section titled “HookOnButtonNavigateStarted”type HookOnButtonNavigateStarted = ( data: HookCommonPropertiesSurvey & { response: { id: string; }; button: { url: string; url_target?: string; }; },) => void;HookOnButtonNavigateCompleted
Section titled “HookOnButtonNavigateCompleted”type HookOnButtonNavigateCompleted = ( data: HookCommonPropertiesSurvey & { response: { id: string; }; button: { url: string; url_target?: string; }; },) => void;For complete hook payload definitions, see the JS tag hooks reference.
Type definitions
Section titled “Type definitions”type PropertyType = number | boolean | string | Date | PropertyRecord;
type PropertyRecord = { [key: string]: PropertyType | PropertyType[];};
type ScreebEndpoints = { rpc?: string; static?: string; report?: string; hostedPage?: string; centipede?: string;};
type ScreebOptions = { window?: Window;
sdkName?: string; sdkVersion?: string;
screebEndpoint?: string;
endpoints?: ScreebEndpoints;
platform?: string;};
type SpaNavigationHandler = (url: string) => void | Promise<void>;
type ScreebFunction = (..._: unknown[]) => void | Promise<unknown>;
type ScreebObject = ScreebFunction & { q?: { args: unknown[]; ko: (reason?: unknown) => void; ok: (value?: unknown) => void; v: number; }[];};
type ScreebIdentityGetReturn = { anonymous_id: string; user_id: string; session_id: string; session_start: string; session_end: string; channel_id: string; is_ready: boolean;};
type ChannelType = "widget" | "ios" | "android";
type Channel = { id: string; type: ChannelType;};
type User = { anonymous_id: string; userId?: string;};
type SurveyFormat = "conversationnal" | "cards";
type SurveySize = 25 | 50 | 75 | 100 | 125 | 150;
type SurveyPosition = | "center-left" | "center-center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right";
type Survey = { id: string; survey_position: SurveyPosition; survey_format: SurveyFormat; survey_size: 100;};
type Message = { id: string; messagey_size: 100;};
type ResponseStatus = | "displayed" | "started" | "ended" | "closed" | "interrupted";
type ResponseItemQuestion = { id: string; title: string; type: "text" | "video"; url?: string;};
type ResponseItemAnswer = { replied_at?: string; fields?: { type: "string" | "number" | "boolean" | "none" | "time" | "file"; text?: string; number?: number; boolean?: boolean; time?: string; }[];};
type ResponseItem = { question: ResponseItemQuestion; answer: ResponseItemAnswer;};
type HookCommonProperties = { channel: Channel; user: User;};
type HookCommonPropertiesSurvey = HookCommonProperties & { survey: Survey;};
type HookCommonPropertiesMessage = HookCommonProperties & { message: Message;};
type HookOnReady = (data: { channel: Channel; user: User }) => void;
type HookOnSurveyDisplayAllowed = ( data: HookCommonPropertiesSurvey,) => boolean;
type HookOnMessageDisplayAllowed = ( data: HookCommonPropertiesSurvey,) => boolean;
type HookOnSurveyShowed = ( data: HookCommonPropertiesSurvey & { response: { id: string; items: ResponseItem[]; }; },) => void;
type HookOnSurveyStarted = ( data: HookCommonPropertiesSurvey & { response: { id: string; }; },) => void;
type HookOnSurveyCompleted = ( data: HookCommonPropertiesSurvey & { response: { id: string; items: ResponseItem[]; }; },) => void;
type HookOnSurveyHidden = ( data: HookCommonPropertiesSurvey & { response: { id: string; items: ResponseItem[]; hide_reason: ResponseStatus; }; },) => void;
type HookOnMessageShowed = ( data: HookCommonPropertiesMessage & { response: { id: string; items: ResponseItem[]; }; },) => void;
type HookOnMessageStarted = ( data: HookCommonPropertiesMessage & { response: { id: string; }; },) => void;
type HookOnMessageCompleted = ( data: HookCommonPropertiesMessage & { response: { id: string; items: ResponseItem[]; }; },) => void;
type HookOnMessageHidden = ( data: HookCommonPropertiesMessage & { response: { id: string; items: ResponseItem[]; hide_reason: ResponseStatus; }; },) => void;
type HookOnQuestionReplied = ( data: HookCommonPropertiesSurvey & { response: { id: string; status: null; question: ResponseItemQuestion; answer: ResponseItemAnswer; items: ResponseItem[]; }; },) => void;
type HookOnButtonNavigateStarted = ( data: HookCommonPropertiesSurvey & { response: { id: string; }; button: { url: string; url_target?: string; }; },) => void;
type HookOnButtonNavigateCompleted = ( data: HookCommonPropertiesSurvey & { response: { id: string; }; button: { url: string; url_target?: string; }; },) => void;
type HooksSurveyStart = { onSurveyShowed?: HookOnSurveyShowed; onSurveyStarted?: HookOnSurveyStarted; onSurveyCompleted?: HookOnSurveyCompleted; onSurveyHidden?: HookOnSurveyHidden;
onQuestionReplied?: HookOnQuestionReplied;
onButtonNavigateStarted?: HookOnButtonNavigateStarted; onButtonNavigateCompleted?: HookOnButtonNavigateCompleted;};
type HooksMessageStart = { onMessageShowed?: HookOnMessageShowed; onMessageStarted?: HookOnMessageStarted; onMessageCompleted?: HookOnMessageCompleted; onMessageHidden?: HookOnMessageHidden;
onQuestionReplied?: HookOnQuestionReplied;
onButtonNavigateStarted?: HookOnButtonNavigateStarted; onButtonNavigateCompleted?: HookOnButtonNavigateCompleted;};
type HooksInit = HooksSurveyStart & HooksMessageStart & { version: string;
onReady?: HookOnReady;
onSurveyDisplayAllowed?: HookOnSurveyDisplayAllowed; onMessageDisplayAllowed?: HookOnMessageDisplayAllowed; };