Skip to main content
Version: Svelte SDK

Reference

Complete reference for all functions available via useScreeb().

closeโ€‹

Shuts down the current Screeb session and removes the Screeb tag from the DOM.

const { close } = useScreeb();
await close();

debugโ€‹

Prints the current state of the Screeb tag to the browser console.

const { debug } = useScreeb();
await debug();

eventTrackโ€‹

Tracks a user event.

const { eventTrack } = useScreeb();
await eventTrack("Product added to cart", { price: 299 });
ParameterTypeRequiredDescription
eventNamestringYesEvent name (max 128 chars)
eventPropertiesPropertyRecordNoKey/value properties

identityโ€‹

Changes the current user identity. Running surveys will be closed.

const { identity } = useScreeb();
await identity("<user-id>", { plan: "pro" });
ParameterTypeRequiredDescription
userIdstringYesUnique user identifier
userPropertiesPropertyRecordNoUser properties

identityGetโ€‹

Returns the current user identity.

const { identityGet } = useScreeb();
const id = await identityGet();

Returns: { anonymous_id, user_id, session_id, session_start, session_end, channel_id, is_ready }

identityGroupAssignโ€‹

Assigns the current user to a group.

const { identityGroupAssign } = useScreeb();
await identityGroupAssign("company", "Apple", { city: "Cupertino" });
ParameterTypeRequired
groupNamestringYes
groupTypestringNo
groupPropertiesPropertyRecordNo

identityGroupUnassignโ€‹

Unassigns the current user from a group.

const { identityGroupUnassign } = useScreeb();
await identityGroupUnassign("company", "Apple");

identityPropertiesโ€‹

Adds or updates user properties. Pass null to delete a property.

const { identityProperties } = useScreeb();
await identityProperties({ plan: "pro", legacy_field: null });

identityResetโ€‹

Resets the current user identity. A new anonymous identity is created.

const { identityReset } = useScreeb();
await identityReset();

initโ€‹

Initializes the Screeb tag.

const { init } = useScreeb();
await init("<website-id>", "<user-id>", { plan: "pro" }, hooks, "en");
ParameterTypeRequired
websiteIdstringYes
userIdstringNo
userPropertiesPropertyRecordNo
hooksHooksInitNo
languagestringNo

loadโ€‹

Manually loads the Screeb tag script. Called automatically by the provider unless shouldLoad: false.

const { load } = useScreeb();
await load();

messageCloseโ€‹

Closes the currently running in-app message.

const { messageClose } = useScreeb();
await messageClose();

messageStartโ€‹

Starts an in-app message by its ID.

const { messageStart } = useScreeb();
await messageStart("<message-id>", true, { color: "green" }, hooks, "en");
ParameterTypeRequired
messageIdstringYes
allowMultipleResponsesbooleanNo (default: true)
hiddenFieldsPropertyRecordNo
hooksHooksMessageStartNo
languagestringNo

sessionReplayStartโ€‹

Starts a session replay recording.

const { sessionReplayStart } = useScreeb();
await sessionReplayStart();

sessionReplayStopโ€‹

Stops the current session replay recording.

const { sessionReplayStop } = useScreeb();
await sessionReplayStop();

surveyCloseโ€‹

Closes the currently running survey.

const { surveyClose } = useScreeb();
await surveyClose();

surveyStartโ€‹

Starts a survey by its ID.

const { surveyStart } = useScreeb();
await surveyStart("<survey-id>", "<distribution-id>", false, hiddenFields, hooks, "en", "#container");
ParameterTypeRequired
surveyIdstringYes
distributionIdstringNo
allowMultipleResponsesbooleanNo (default: false)
hiddenFieldsPropertyRecordNo
hooksHooksSurveyStartNo
languagestringNo
selectorsstring | string[]No

targetingCheckโ€‹

Forces a targeting rule evaluation.

const { targetingCheck } = useScreeb();
await targetingCheck();

targetingDebugโ€‹

Prints the current targeting engine state.

const { targetingDebug } = useScreeb();
await targetingDebug();