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 Life Cycle, Session, User.
User identifier
To specify the user identifier:
Smartlook.instance.user.setIdentifier("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.instance.user.setName("John Doe");
Smartlook.instance.user.setEmail("[email protected]");Both
user.nameanduser.emailact as an alias. They are added touser.propertiesunder thenameand
User properties
User properties can be added via the following methods:
Smartlook.instance.user.setUserProperty('property-name','property-value');
const propertyValue = await Smartlook.instance.user.getUserProperty('property-name');
Smartlook.instance.user.removeUserProperty('property-name');
Properties APIFull documentation on using
put,get, andremoveproperties can be found in the properties section.
Opening a new user
The current user can be closed and a new user opened:
Smartlook.instance.user.openNewUser();
New user sessionOpening a new user opens a new session. For more information on user sessions, see Lifecycle, Session, User.
User URL
The URL of the currently recorded user can be obtained:
const userUrl = await Smartlook.instance.user.getUserUrl();
Nullability and shareabilityThe
URLis only available when the SDK is able to communicate with the Smartlook backend. Otherwise, it isnull.The
URLis 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. Can be asynchronous.
function userUrlChangedCallback(userUrl: string) {
console.log('Emitted user url', userUrl);
}
Smartlook.instance.eventListeners.registerUserChangedListener(
userUrlChangedCallback
);