iOS User Information

Tracking User Information

After you install SDK to your app, Reteno begins automatically collect such data:

Reteno 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.

šŸ“˜

Note

The External User Id identifies the contact, but it is not the unique key of events sent from the mobile SDK. The unique key of an SDK event is always the deviceId, on iOS and on Android alike. Look events up by deviceId 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 Reteno by the following method:

Reteno.updateUserAttributes(externalUserId: "USER_ID", attributes: UserAttributes)
šŸ“˜

Note

When a user logs in to the app under a different External User Id, the device and its push token are re-linked to the contact with that identifier, and the previous contact loses this device and token. One contact can have multiple devices and receives push notifications on all of them.

ā—ļø

Pass the ID and the attributes in one call

Send the External User Id together with the user attributes in a single updateUserAttributes(externalUserId:attributes:) call. Don't split it into consecutive calls — first the ID, then the attributes — because part of the attributes may not be saved.

Set anonymous attributes with updateAnonymousUserAttributes() before the user is identified. Once you call updateUserAttributes with an External User Id, the anonymous data is merged into the identified contact.

When to send your user ID to Reteno >

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 Reteno. Read more on how to set additional fields.

šŸ“˜

Note

You can track user attributes only for users with external user IDs.

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

groupNamesInclude and groupNamesExclude parameters 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]
}
šŸ“˜

Note

key

Custom fields variables. Details >

phone

We 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.

languageCode

Data about language in RFC 5646 format. Primary language subtag in ISO 639-1 format is required. Example: de-AT

timeZone

Item 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)
šŸ“˜

Note

You 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
  )