Reference
Complete reference for @screeb/sdk-angular.
✨ New to Screeb? Start with the Install guide.
Screeb service methods
Inject Screeb service and call these methods. All methods return a Promise.
| Method | Description | More |
|---|---|---|
load(options?) | Loads the Screeb tag into your application. Usually called automatically by ScreebModule. | Install |
init(websiteId, userId?, userProperties?, hooks?, language?) | Initializes the Screeb SDK. Usually called automatically when autoInit: true. | Install |
close() | Shuts down the current Screeb session and removes the widget from the page. | Install |
identity(userId, userProperties?) | Sets or updates the current user identity. | Identity |
identityGet() | Retrieves the current user identity. | Identity |
identityProperties(userProperties) | Updates properties for the current user. | Identity |
identityReset() | Resets the current user identity (logout). | Identity |
identityGroupAssign(groupName, groupType?, groupProperties?) | Assigns the current user to a group. | Group assignation |
identityGroupUnassign(groupName, groupType?) | Unassigns the current user from a group. | Group assignation |
eventTrack(eventName, eventProperties?) | Tracks a custom event. | Event tracking |
surveyStart(surveyId, distributionId, allowMultipleResponses, hiddenFields?, hooks?, language?, selectors?) | Starts a survey programmatically. | Start survey |
surveyClose() | Closes the currently running survey. | Start survey |
messageStart(messageId, allowMultipleResponses?, hiddenFields?, hooks?, language?) | Starts a message programmatically. | Start message |
messageClose() | Closes the currently running message. | Start message |
sessionReplayStart() | Starts a session replay. | - |
sessionReplayStop() | Stops the current session replay. | - |
targetingCheck() | Forces a targeting check. | - |
targetingDebug() | Prints the current state of the targeting engine. | Troubleshooting |
debug() | Prints the current state of the Screeb SDK. | Troubleshooting |
ScreebModule configuration
When calling ScreebModule.forRoot(config), the following options are available:
| Option | Type | Required | Description |
|---|---|---|---|
autoInit | boolean | No | If true, the SDK is initialized automatically. Default: false. |
websiteId | string | Yes | Your Screeb channel/website ID. |
userId | string | No | The unique identifier of your user. |
userProperties | PropertyRecord | No | Initial user properties. |
hooks | HooksInit | No | Hooks to execute on SDK events. |
shouldLoad | boolean | No | If false, the SDK tag will not be loaded. Default: true. |
Note: The
languageparameter is not available inScreebModule.forRoot(). To set the language, use thelanguageparameter when callinginit()directly.
Type definitions
type PropertyType = number | boolean | string | Date | PropertyRecord;
type PropertyRecord = {
[key: string]: PropertyType | PropertyType[];
};
interface HooksInit {
version?: string;
onReady?: (payload: any) => void;
onSurveyShowed?: (payload: any) => void;
onSurveyStarted?: (payload: any) => void;
onQuestionReplied?: (payload: any) => void;
onSurveyCompleted?: (payload: any) => void;
onSurveyHidden?: (payload: any) => void;
onMessageShowed?: (payload: any) => void;
onMessageStarted?: (payload: any) => void;
onMessageCompleted?: (payload: any) => void;
onMessageHidden?: (payload: any) => void;
onSurveyDisplayAllowed?: (payload: any) => boolean;
onMessageDisplayAllowed?: (payload: any) => boolean;
}
interface HooksSurveyStart {
onSurveyShowed?: (payload: any) => void;
onSurveyStarted?: (payload: any) => void;
onQuestionReplied?: (payload: any) => void;
onSurveyCompleted?: (payload: any) => void;
onSurveyHidden?: (payload: any) => void;
}
interface HooksMessageStart {
onMessageShowed?: (payload: any) => void;
onMessageStarted?: (payload: any) => void;
onQuestionReplied?: (payload: any) => void;
onMessageCompleted?: (payload: any) => void;
onMessageHidden?: (payload: any) => void;
}
For complete hook payload definitions, see the JS tag hooks reference.