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 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");
| 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();