Skip to content
Open Screeb

Every public method of @screeb/sdk-browser, with its signature.

Complete reference for @screeb/sdk-browser. New to Screeb? Start with the install guide.

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
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
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
Method Description More
eventTrack(eventName: string, eventProperties?: PropertyRecord) Tracks a user event. Guide
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
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
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
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
export function init(websiteId: string, userId?: string, userProperties?: PropertyRecord, hooks?: HooksInit, language?: string, spaNavigationHandler?: SpaNavigationHandler);
export function load(options?: ScreebOptions);
export function close();
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>;
export function identityGroupAssign(groupName: string, groupType?: string, groupProperties?: PropertyRecord);
export function identityGroupUnassign(groupName: string, groupType?: string);
export function eventTrack(eventName: string, eventProperties?: PropertyRecord);
export function surveyStart(surveyId: string, distributionId?: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksSurveyStart, language?: string, selectors?: string | string[]);
export function surveyClose();
export function messageStart(messageId: string, allowMultipleResponses?: boolean, hiddenFields?: PropertyRecord, hooks?: HooksMessageStart, language?: string);
export function messageClose();
export function sessionReplayStart();
export function sessionReplayStop();
export function debug();
export function targetingDebug();
export function isLoaded();
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;
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;

For complete hook payload definitions, see the JS tag hooks reference.

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;
};