Identity
Set identity
On a logged page, identify who responded to surveys by calling identity. This lets you track users across sessions and platforms.
Requirements:
- The unique visitor id must be between 1 and 255 characters.
On init
import * as Screeb from "@screeb/sdk-browser";
Screeb.load();
Screeb.init(
"<YOUR-CHANNEL-ID>",
"<USER-ID>",
{
firstname: "<user-firstname>",
lastname: "<user-lastname>",
plan: "<user-plan>",
last_seen_at: new Date(),
authenticated: true,
}
);
After init
Screeb.identity("<USER-ID>");
// With properties
Screeb.identity("<USER-ID>", {
email: "support@screeb.app",
plan: "growth-monthly",
});
Reset identity (logout)
Screeb.identityReset();
Update properties
Screeb.identityProperties({
email: "support@screeb.app",
age: 42,
logged: true,
signed_up_at: new Date(),
});
// Delete a property by setting it to null
Screeb.identityProperties({ company: null });
Get current identity
const identity = await Screeb.identityGet();
// {
// channel_id: "...",
// anonymous_id: "...",
// user_id: "user-42",
// is_ready: true,
// session_id: "...",
// session_start: "...",
// session_end: "..."
// }