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.identifier = "sample-identifier"
Smartlook.getInstance().getUser().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.name = "John Doe"
Smartlook.instance.user.email = "[email protected]"
Smartlook.getInstance().getUser().setName("John Doe");
Smartlook.getInstance().getUser().setEmail("[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 as a properties object:

Smartlook.instance.user.properties
Smartlook.getInstance().getUser().getProperties();

πŸ“˜

Properties API

Full documentation on using put, get, and remove properties 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.openNew()
Smartlook.getInstance().getUser().openNew();

πŸ“˜

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:

val userURL = Smartlook.instance.user.url
URL userURL = Smartlook.getInstance().getUser().getUrl();

🚧

Nullability and shareability

The URL is only available when the SDK was 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:

Smartlook.instance.user.listeners += object : User.Listener {
  override fun onUrlChanged(url: URL) {
        // Called when user URL changes
  }
}
Smartlook.getInstance().getUser().getListeners().add(
  url -> {
        // Called when user URL changes
  }
);

πŸ“˜

Multiple listeners

Multiple User.Listener can be registered and work in parallel.