Smartlook records user interactions sessions. Every session has a single user and a single user can have multiple sessions. For more information on users, see Lifecycle, session, user.
User identifier
To specify the user identifier:
Smartlook.setUserIdentifier({ identifier: "sample-identifier" });
Identifier restrictions
- Cannot be null or empty
- Maximum length is 120 characters.
User name and email
The name
and email
properties can be directly set using:
Smartlook.setUserName({ name: "John Doe" });
Smartlook.setUserEmail({ email: "[email protected]" });
Both
user.name
anduser.email
act as an alias. They are added touser.properties
under thename
and
User properties
User properties can be added using the following methods:
Smartlook.setUserProperty({ propertyName: 'property-name', value: 'property-value' });
Smartlook.instance.user.removeUserProperty({ propertyName: 'property-name' });
Smartlook.getUserProperty({ propertyName: 'property-name' }, successCallback);
function successCallback(userPropertyValue: string) {
console.log('User prop value:' + userPropertyValue);
}
Opening a new user
The current user can be closed and a new user opened:
Smartlook.openNewUser();
New user session
Opening a new user opens a new session. For more information, see Lifecycle, session, user.
User URL
The URL
of the currently recorded user can be obtained:
Smartlook.getUserUrl(successCallback);
function successCallback(userUrl: string) {
console.log('User url:' + userUrl);
}
Nullability and shareability
The
URL
is only available when the SDK is able to communicate with the Smartlook backend. Otherwise, it isnull
.The
URL
is not publicly sharable. You must log in to the dashboard.
User Listeners
A listener can be registered to listen for visitor URL changes:
// A callback function that gets called when the user URL changes.
function urlChangedCallback(userUrl: string) {
console.log('Emitted user url', userUrl);
}
Smartlook.registerUserUrlChangedListener({
userUrlChangedCallback: urlChangedCallback
});