Create user identity

Each time a new session is started by a user who can be identified (your system has logged the user’s personal data) SessionStack allows you to associate him/her with the current session by assigning the user a unique cookie. If the user is anonymous, he’ll automatically get assigned a unique ID and name. As soon as the ‘identify’ command is called, the user will no longer be anonymous and his browsing data will be reconciled with the automatically assigned identifier.

sessionstack('identify', {
    userId: 'USER-ID' // Your app user id
});

More personal details like email or display name can be easily stored.

sessionstack('identify', {
    userId: 'USER-ID',
    email: '[email protected]',
    displayName: 'John Smith'
});

Along with email/display name, SessionStack lets you save custom data too.

sessionstack('identify', {
    userId: 'USER-ID', // Required
    email: '[email protected]', // Not required
    displayName: 'John Smith', // Not required

    // Add your own custom user variables here.
    role: 'user',
    pricingPlan: 'free'
});

📘

Note

All custom fields must be key/value pairs.

📘

Note

You should not be using the ‘identify’ command for anonymous or guest users, since you don’t actually know who they are.

All user data can be used for searching specific sessions.

Update user identity

All user identity data (except user ID) can be modified during the session. You need to call the identify command with the value(s) you want to update.

If you have identified user with userId: ‘USER-ID’ and email: '[email protected]‘, and you want to change the email to '[email protected]‘, call the identify command with the same userId and the new email

sessionstack('identify', {
    userId: 'USER-ID',
    email: '[email protected]'
});

If you need to add user identity data during the session, call the ‘identify’ command passing user ID and the new data as key/value pairs.

sessionstack('identify', {
    userId: 'USER-ID',
    displayName: 'John Smith'
});

You can set user email or display name the same way.

Restrictions

All fields must be of type Sstring*. Main fields (userId, email and displayName) are limited up to 128 characters each. Custom fields keys and values should not be longer than 512 characters.

📘

Note

Values longer than the maximum length will be automatically trimmed to fit.