User

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 and user.email act as an alias. They are added to user.properties under the name and email keys.

User properties

User properties can be added via the following methods:

Smartlook.setUserProperty({ propertyName: 'property-name', value: 'property-value' });

Smartlook.instance.user.removeUserProperty({ propertyName: 'property-name' });

const userProperty = await Smartlook.getUserProperty({ propertyName: 'property-name' });

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 on user sessions, see Lifecycle, session, user.

User URL

The URL of the currently recorded user can be obtained:

const userUrl = await Smartlook.getUserUrl(successCallback);

🚧

Nullability and shareability

The URL is only available when the SDK is able to communicate with the Smartlook backend. Otherwise, it is null.

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
});