Skip to main content
Version: Angular SDK

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.

MethodDescriptionMore
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:

OptionTypeRequiredDescription
autoInitbooleanNoIf true, the SDK is initialized automatically. Default: false.
websiteIdstringYesYour Screeb channel/website ID.
userIdstringNoThe unique identifier of your user.
userPropertiesPropertyRecordNoInitial user properties.
hooksHooksInitNoHooks to execute on SDK events.
shouldLoadbooleanNoIf false, the SDK tag will not be loaded. Default: true.

Note: The language parameter is not available in ScreebModule.forRoot(). To set the language, use the language parameter when calling init() 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.