Skip to main content
Version: iOS SDK

Identity

Set identityโ€‹

Tip: If you already know the user's ID at startup, pass it directly to Screeb.initSdk() to avoid creating an anonymous visitor.

When a user is identified in your app, you won't be able to identify who responded to surveys until you call the setIdentity command.

Thanks to this, you will be able to track this user over multiple platforms (desktop, mobile, tablet...).

The identifier of your app user must be unique and idempotent. User email is good, but can change over time. We recommend that you use the user id.

Requirements:
  • The unique app user id must have a length between 1 to 255 characters.
import Screeb
...
// assign current session to a user identifier (such as your internal user id, an email address...)
Screeb.setIdentity(uniqueVisitorId: "<USER-ID>")

// You can also add properties (see Attributes configuration below) when calling identity command :
Screeb.setIdentity(uniqueVisitorId: "<USER-ID>", visitorProperty: [
"age": 27,
"category": "cycle",
"purchasedAt": ISO8601DateFormatter().string(from: Date())
])

Reset current identityโ€‹

When the user logs out, please call the resetIdentity command.

This command must be called only once, since it creates a new identity on Screeb side. If you call it on every anonymous view, you won't be able to track app usage and surveys will be sent many times to the same app user.

Screeb.resetIdentity()

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 app user identifier.

Attributesโ€‹

Screeb allows tracking some custom data about your app users. 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 (Int, Long, Double), boolean and dates as ISO 8601 strings.
import Screeb
...
// set visitor properties
Screeb.visitorProperty(visitorProperty: [
"email": "support@screeb.app",
"age": 29,
"logged": true,
"signed_up_at": ISO8601DateFormatter().string(from: Date()),
])

// Delete visitor property: set values to nil
Screeb.visitorProperty(visitorProperty: [
"email": "support@screeb.app",
"age": 29,
"logged": NSNull(),
"signed_up_at": ISO8601DateFormatter().string(from: Date()),
])

Good practices with an existing CDPโ€‹

When Amplitude, Segment or RudderStack is a Screeb source, Screeb resolves the respondent of each forwarded event from its user id, or from its anonymous id when the visitor is not logged in. Once both ids appear on the same event, Screeb aliases them to one respondent, so a visitor who logs in keeps a single profile. Screeb never moves an id from one respondent to another, and it does not read your CDP's identifiers from your app: keeping the two tools on the same identifiers is part of your instrumentation. Three rules do it.

1. One user id, the same string everywhereโ€‹

Identify the user in Screeb with exactly the value you give your CDP's identify: a stable internal id rather than an email, which can change. Do it in the same place in your code so neither tool lags behind the other.

Screeb.setIdentity(uniqueVisitorId: userId)

Amplitude drops user ids and device ids shorter than 5 characters, and the event then reaches Screeb as anonymous: use ids of 5 characters or more.

2. Tell Screeb which anonymous id your CDP usesโ€‹

Before login, CDP events carry only the CDP's own anonymous id (Amplitude device id, Segment and RudderStack anonymous id). Give that id to Screeb with Screeb.setAnonymousId(anonymousId:): the current respondent adopts it and stays anonymous. When the CDP integration already created a respondent for that id, Screeb switches to it, so the events it already received are not lost. An identified respondent is never switched away from: the id then stays with its owner. If Screeb switches, any survey running for the previous respondent closes, as with resetIdentity.

if let deviceId = amplitude.getDeviceId() {
Screeb.setAnonymousId(anonymousId: deviceId)
}

Call it right after initSdk: the call is queued and resolved during init, before any respondent is created, so the two calls behave like a single init option. Calling it later works too.

The id must be 5 to 128 characters. Calling it again with the same id does nothing. Nothing changes in your CDP installation: Screeb never writes to it, and other tools wired to your CDP are not affected.

Do not pass the CDP anonymous id to setIdentity: that turns it into a user identity, and the real login then creates a second respondent instead of merging.

If you cannot read the CDP anonymous id in the app, the reverse also works: read the Screeb anonymous id with Screeb.getIdentity and give it to your CDP as its device or anonymous id before the CDP sends its first event. Prefer the recipe above: changing your CDP's device id also changes it for every other tool connected to that CDP.

3. Reset both tools together on logoutโ€‹

Reset Screeb, reset your CDP, then give Screeb the CDP's new anonymous id. Reset once, on logout only: resetting on every anonymous screen creates a new respondent each time on both sides.

Each reset starts a new anonymous id, and a respondent holds at most 20 ids: past that, a new anonymous id is no longer attached to it, and later CDP events carrying only that id create an anonymous respondent.

Screeb.resetIdentity()
amplitude.reset()
if let deviceId = amplitude.getDeviceId() {
Screeb.setAnonymousId(anonymousId: deviceId)
}

What the "ignore anonymous users" settings changeโ€‹

The integration's "ignore events from anonymous users" option and the workspace-level "Ignore anonymous users" setting drop CDP events that carry no user id. Rule 2 needs both off to cover the pre-login window: the workspace setting also refuses the adoption on an anonymous respondent (anonymous_user_not_allowed). An event carrying a user id is never dropped by them, so the login-time merge happens either way.

Check it worksโ€‹

Read the current identity and compare anonymous_id and user_id with what your CDP reports for the same visitor. In Screeb, the respondent page lists the CDP anonymous id among its aliases, then the user id after login, and a survey targeted on a CDP event displays a few seconds after the event.