Identity
Set identity
On a logged page of your website, you won't be able to identify who responded to surveys until you call the identity
command.
Thanks to this, you will be able to track this user over multiple platforms (desktop, mobile, tablet...).
The identifier of your website visitor must be unique and idempotent. User email is good, but can vary over time. We recommend using the user id.
Requirements:- The unique visitor id must have a length between 1 to 255 characters.
Set identity on widget start
If identity
is empty, the last identity will be used. If the Javascript widget is loaded for the first time, an anonymous identity will be created instead.
$screeb('init', '<website-id>', {
identity: {
// Assign current session to a visitor identifier,
// such as your internal id, an email address...
id: '<unique-visitor-id>',
// Set visitor properties (optional)
properties: {
firstname: '<user-firstname>',
lastname: '<user-lastname>',
plan: '<user-plan>',
last_seen_at: new Date(),
authenticated: true,
}
}
});
Set identity later
You can change the current visitor identity at any time. Running surveys will be closed.
// assign current session to a visitor identifier (such as your internal user id, an email address...)
$screeb('identity', '<unique-visitor-id>');
Reset current identity
When the user logs out, please call the reset
command.
This command must be called only once, since it creates a new identity on Screeb side. If you call it on every anonymous page, you won't be able to track visitor navigation and surveys will be sent many times to the same visitor.
$screeb('identity.reset');
Ignore anonymous user
If you want to ignore anonymous users and only track identified users, you can use the ignore Anonymous
option. This will ensure that no data is collected for users who have not been identified.
To Activate the ignore Anonymous
option, go to your screeb workspace settings and set the ignore Anonymous
option to true
.
(go to your workspace Settings)
By setting ignore Anonymous
to true
, the widget will not collect any data until the identity
command is called with a unique visitor identifier.
Attributes
Screeb allows tracking some custom data about your website visitors. Those properties can be inserted as "hidden fields" in your surveys or can be used for an advanced targeting rule.
Requirements:- Property names must be limited to 128 characters
- No more than 1000 attributes
- Supported types for values: string, number, boolean and Date.
// set visitor properties
$screeb('identity.properties', {
email: '[email protected]',
age: 42,
logged: true,
signed_up_at: new Date(),
});
// Delete visitor property : set values to null
$screeb('identity.properties', {
email: '[email protected]',
age: null,
company: null,
logged: true,
});
identity
and identity.properties
can be executed in the same command:
// Last argument is optional
$screeb('identity', '<unique-visitor-id>', { email: '[email protected]', plan: 'growth-monthly' });
Get current identity
You can get the current visitor identity at any time.
$screeb('identity.get').then(console.log);
// {
// channel_id: "0e2b609a-8dce-4695-a80f-966fbfa87a88",
// anonymous_id: "30311998-5bc4-4cb7-8aca-d4189319b450", // generated by Screeb
// user_id: "user-42", // null if visitor has not been identified
// is_ready: true, // false if screeb respondent is not initialised yet
// session_id: "eeba641a-f831-44cb-9d9e-5224ffc5b91b",
// session_start: "2023-02-01T17:07:50.097Z",
// session_end: "2023-02-01T17:32:57.632Z"
// }