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 });
| Parameter | Type | Required | Description |
|---|---|---|---|
eventName | string | Yes | Event name (max 128 chars) |
eventProperties | PropertyRecord | No | Key/value properties |
identity
Changes the current user identity. Running surveys will be closed.
const { identity } = useScreeb();
await identity("<user-id>", { plan: "pro" });
| Parameter | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | Unique user identifier |
userProperties | PropertyRecord | No | User 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" });
| Parameter | Type | Required |
|---|---|---|
groupName | string | Yes |
groupType | string | No |
groupProperties | PropertyRecord | No |
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");
| Parameter | Type | Required |
|---|---|---|
websiteId | string | Yes |
userId | string | No |
userProperties | PropertyRecord | No |
hooks | HooksInit | No |
language | string | No |
load
Manually loads the Screeb tag script. Called automatically by the plugin 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");
| Parameter | Type | Required |
|---|---|---|
messageId | string | Yes |
allowMultipleResponses | boolean | No (default: true) |
hiddenFields | PropertyRecord | No |
hooks | HooksMessageStart | No |
language | string | No |
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");
| Parameter | Type | Required |
|---|---|---|
surveyId | string | Yes |
distributionId | string | No |
allowMultipleResponses | boolean | No (default: false) |
hiddenFields | PropertyRecord | No |
hooks | HooksSurveyStart | No |
language | string | No |
selectors | string | 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();