Tracking User Information
After you install SDK to your app, eSputnik begins automatically collect such data:
- Information about push message delivery and openings,
- Users’ push tokens,
- Screen view events,
- Statuses of the users’ subscription to push notifications.
eSputnik automatically creates user profiles with all these data, so you can immediately start working with new contacts, for example, sending them a mobile campaign.
When the user logs in or signs up to your app, you have to define a unique customer identifier that cannot be shared by other contacts. We call it External User Id or just User Id. The system will match all previous data with an external ID as the primary identifier and update the user’s profile.
External User Id is not the event keyThe unique key of an event sent by the mobile SDK is always
deviceId, on both iOS and Android. External User Id identifies the contact, but you cannot use it to look up SDK events by key in Automation → Event history.
Read more about system customer identifiers and their matching in the system >
External User ID
Add your custom External User Ids within eSputnik by the following method:
Reteno.updateUserAttributes(externalUserId: "USER_ID", attributes: UserAttributes)When to send your user ID to eSputnik >
User Attributes
User attributes are attributes you define to describe segments of your user base, such as language preference or geographic location. Before sending specific contact data via API, you must add custom user fields to eSputnik. Read more on how to set additional fields.
NoteYou can track user attributes only for users with external user IDs.
Order of callsPass the external user ID and the user attributes in a single
updateUserAttributes(externalUserId:userAttributes:)call. Sending the ID first and the attributes in a separate call afterwards may leave part of the attributes unsaved.Set anonymous attributes before the user is identified. After the first call with an External User Id, the anonymous data is merged into the contact.
Add user attributes like phone, email, etc by the following method:
Reteno.updateUserAttributes(externalUserId: "USER_ID", userAttributes: UserAttributes, subscriptionKeys: [String], groupNamesInclude: [String], groupNamesExclude: [String])
Note
groupNamesIncludeandgroupNamesExcludeparameters are available in SDK version 1.0.0 or later.
The UserAttributes object structure:
public struct UserCustomField {
let key: String
let value: String
}
public struct Address {
let region: String?
let town: String?
let address: String?
let postcode: String?
}
public struct UserAttributes {
let phone: String?
let email: String?
let firstName: String?
let lastName: String?
let languageCode: String?
let timeZone: String?
let address: Address?
let fields: [UserCustomField]
}
NotekeyCustom fields variables. Details >
phoneWe use Google's libphonenumber library for phone number validation. Send phone numbers in the E164 format. A request with an invalid phone number will not be transmitted. You can validate phone numbers by the link.
languageCodeData about language in RFC 5646 format. Primary language subtag in ISO 639-1 format is required. Example: de-AT
timeZoneItem from TZ database. Example:
Europe/Kyiv
Anonymous User Attributes
Reteno SDK allows tracking anonymous user attributes. To start tracking information about user without identificator, use updateAnonymousUserAttributes() method:
let attributes = AnonymousUserAttributes(
firstName: user.firstName,
lastName: user.lastName,
timeZone: TimeZone.current.identifier,
fields: [
UserCustomField(key: "LIST_NAME.FIELD_NAME", value: "Ukraine")
]
)
Reteno.updateAnonymousUserAttributes(userAttributes: attributes)
NoteYou can't provide to the SDK anonymous user phone and email attributes.
Multi-account Support
Since 2.5.11 it is possible to share push notification token between user accounts.
If it is required to receive push notifications on accounts that aren't currently logged in,
but they share the same device, use the updateMultiAccountUserAttributes method.
/// Update MultiAccount User attributes
/// - Parameter externalUserId: Id for identify user in a system (optional)
/// - Parameter userAttributes: user specific attributes in format UserAttributes (firstName, phone, email, etc.) (optional)
/// - Parameter subscriptionKeys: list of subscription categories keys, can be empty
/// - Parameter groupNamesInclude: list of group ID to add a contact to, can be empty
/// - Parameter groupNamesExclude: list of group ID to remove a contact from, can be empty
/// - Parameter accountSuffix: account suffix which will be used in deviceId. Usually accepts external user ID
public static func updateMultiAccountUserAttributes(
externalUserId: String? = nil,
userAttributes: UserAttributes? = nil,
subscriptionKeys: [String] = [],
groupNamesInclude: [String] = [],
groupNamesExclude: [String] = [],
accountSuffix: String? = nil
)