Skip to main content
Version: Javascript tag

Reference

Introductionโ€‹

The reference is your key to a comprehensive understanding of the Screeb Javascript SDK.

โœจ If this is your first look at the documentation, we recommend beginning with the Getting started guide.

$screeb methodsโ€‹

After injecting the Screeb Javascript SDK in your website, you will have access to a global $screeb object. $screeb methods are executed sequentially and return a Promise.

Use the following syntax: $screeb(method, argument1, argument2, ...).

MethodDefinitionMore
initThe init method starts the SDK and associates the current session to your Screeb project. Your website identifier must be passed. Optionally, this method can identify the current user. If no user identifier is provided, an anonymous visitor session is created. You will be able to later change the current user by using the identity method.๐Ÿ‘‰
closeThe close method shutdowns the Screeb SDK. It is the opposite to init.๐Ÿ‘‰
debugThe debug method prints the current configuration of Screeb SDK, with website id, user id, session duration...๐Ÿ‘‰
identityThe identity method tells Screeb who the current user is. When Screeb is only installed on the logged page, please identify users using the init method instead. If your website has public pages, this method allows identifying users lazily, on user login.๐Ÿ‘‰
identity.propertiesThe identity.properties method associates some contextual properties to the current user session. You will be able to personalize surveys and target questions to the right audience.๐Ÿ‘‰
identity.group.assignThe identity.group.assign method assigns the current user to a Screeb segment. Some properties can be passed to the method to contextualize the segment.๐Ÿ‘‰
identity.group.unassignThe identity.group.unassign method unassigns the current user from a Screeb segment.๐Ÿ‘‰
identity.resetThe identity.reset method tells Screeb to reset the current user session and switch to an anonymous user. Please note it won't disable the Javascript SDK until you call the close command.๐Ÿ‘‰
identity.getThe identity.get method allows you to retrieve the current user identity.๐Ÿ‘‰
identity.anonymous_idThe identity.anonymous_id method tells Screeb which anonymous id your CDP already uses for the current visitor.๐Ÿ‘‰
event.trackThe event.track method tracks actions performed by current users, along with properties describing the event.๐Ÿ‘‰
event.screenThe event.screen method reports a screen change to the targeting engine. Only available when the tag runs inside a Screeb-instrumented mobile webview.๐Ÿ‘‰
event.copilotThe event.copilot method tracks actions performed by users with AI copilots, along with properties describing the event.๐Ÿ‘‰
message.startThe message.start method starts a message by providing its id. Optionally, this command can prevent a user to see a single message multiple times. Please note that running a message using message.start will require a developer: to be autonomous, use the Screeb targeting engine instead.๐Ÿ‘‰
message.closeThe message.close method interrupts a message.๐Ÿ‘‰
message.debugThe message.debug method prints the status of each active message and its associated targeting rules.๐Ÿ‘‰
survey.startThe survey.start method starts a survey by providing its id. Optionally, this command can prevent a user to see a single survey multiple times. Please note that running a survey using survey.start will require a developer: to be autonomous, use the Screeb targeting engine instead.๐Ÿ‘‰
survey.closeThe survey.close method interrupts a survey.๐Ÿ‘‰
session-replay.startThe session-replay.start method starts session replay recording. Once started, user interactions will be captured for replay in the Screeb platform.๐Ÿ‘‰
session-replay.stopThe session-replay.stop method stops session replay recording.๐Ÿ‘‰
color-scheme.setThe color-scheme.set method forces the color scheme surveys and messages render in: "light", "dark" or "auto". It overrides the colorScheme init option; "auto" goes back to following your page.๐Ÿ‘‰
targeting.debugThe targeting.debug method prints the status of each targeting rule for each survey of your account.๐Ÿ‘‰

Dark modeโ€‹

Surveys and messages draw your theme's dark values when they render in dark mode. A theme without dark values looks the same in both schemes.

By default ("auto"), the tag picks the scheme from, in order:

  1. in a mobile app webview, the app's appearance;
  2. a marker on your page's <html> element: a dark or light class, a data-theme, data-color-scheme, data-mode or data-bs-theme attribute set to dark or light, or a single color-scheme (dark or light, not light dark);
  3. the visitor's device setting.

To decide yourself, pass the colorScheme option to init ("light", "dark" or "auto"):

$screeb("init", "<website-id>", { colorScheme: "dark" });

The option can also be set before the tag loads, via the window.ScreebConfig object:

window.ScreebConfig = { colorScheme: "dark" };

If your app has its own theme switch that sets none of these markers, call color-scheme.set from it with "dark" or "light". Running surveys and messages update right away:

$screeb("color-scheme.set", "light");
npm module

Screeb.setColorScheme comes to the npm modules (@screeb/sdk-browser and the framework packages) in a later release. Meanwhile, the $screeb("color-scheme.set", โ€ฆ) command works with any installation.

Privacy helpersโ€‹

Privacy annotations are applied as plain HTML classes/attributes rather than $screeb calls. See Privacy helpers.