Tracking User Information
After you install SDK to your app, Yespo 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.
Yespo 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.
Read more about system customer identifiers and their matching in the system >
External User ID
Add your custom External User Ids within Yespo by the following method:
Reteno.setUserAttributes(externalUserId: String)Reteno.setUserAttributes(String externalUserId)externalUserId should not be null or empty, or IllegalArgumentException will be thrown.
Pass the ID and the attributes in one callSend the External User Id together with the user attributes in a single
setUserAttributes(externalUserId, user)call, rather than callingsetUserAttributes(externalUserId)first and sending the attributes afterwards — sequential calls can overlap, and part of the attributes may not be saved.Set anonymous attributes with
setAnonymousUserAttributes()before the user is identified. As soon as you callsetUserAttributes()with an External User Id, the data collected anonymously is merged into that contact.
When a user logs in to the app under a different External User Id, the device together with its push token is re-linked to the contact with that identifier, and the previous contact loses this device and token. One contact can have several devices and receives push notifications on all of them. To keep receiving push notifications on several accounts that share one device, use multi-account support.
The unique key of an event sent by the mobile SDK is always deviceId, on both Android and iOS. External User Id identifies the contact, but you can't use it to look up SDK events by key in Automation → Event history. Read more about customer identifiers and their matching >
When to send your user ID to Yespo >
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 Yespo. Read more on how to set additional fields.
NoteYou can track user attributes only for users with external user IDs.
Add user attributes like phone, email, etc by the following method:
Reteno.setUserAttributes(externalUserId: String, user: User?)Reteno.setUserAttributes(String externalUserId, User user)User model:
{
"userAttributes":{
"phone":"String",
"email":"String",
"firstName":"String",
"lastName":"String",
"languageCode":"String",
"timeZone":"String",
"marketId":"String",
"address":{
"region":"String",
"town":"String",
"address":"String",
"postcode":"String"
},
"fields":[
{
"key":"string",
"value":"string"
},
{
"key":"string",
"value":"string"
}
]
},
"subscriptionKeys":[
"string1",
"string2"
],
"groupNamesInclude":[
"string1",
"string2"
],
"groupNamesExclude":[
"string",
"string2"
]
}The structure of models with optional and required fields:
data class User(
val userAttributes: UserAttributes? = null,
val subscriptionKeys: List<String>? = null,
val groupNamesInclude: List<String>? = null,
val groupNamesExclude: List<String>? = null
)
data class UserAttributes(
val phone: String? = null,
val email: String? = null,
val firstName: String? = null,
val lastName: String? = null,
val languageCode: String? = null,
val timeZone: String? = null,
val marketId: String? = null,
val address: Address? = null,
val fields: List<UserCustomField>? = null,
)
data class Address(
val region: String? = null,
val town: String? = null,
val address: String? = null,
val postcode: String? = null
)
data class UserCustomField(
val key: String,
val value: String? = null
)
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
Available for RetenoSDK starting from version 1.5.3
Reteno SDK allows tracking anonymous user attributes (no externalUserId required). To set user attributes without externalUserId use method setAnonymousUserAttributes():
Reteno.setAnonymousUserAttributes(attributes: UserAttributesAnonymous)Reteno.setAnonymousUserAttributes(UserAttributesAnonymous attributes)UserAttributesAnonymous model:
data class UserAttributesAnonymous(
/**
* Contact first name. Numbers cannot be used
*/
val firstName: String? = null,
/**
* Contact last name. Numbers cannot be used
*/
val lastName: String? = null,
/**
* Data about language in RFC 5646 format.
* Primary language subtag in ISO 639-1 format is required.
* Example: de-AT
*/
val languageCode: String? = null,
/**
* Item from TZ database. Example: Europe/Kyiv.
* See column [TZ database name](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
*/
val timeZone: String? = null,
/**
* Contact full address
*
* @see Address
*/
val address: Address? = null,
/**
* Additional field values for contact
*
* @see UserCustomField
*/
val fields: List<UserCustomField>? = null,
/**
* Market ID
*
* Max length: 64 char
* Allowed symbols: latin symbols, numbers and `-`, `_`
* To be able to clear market id, pass empty string, null values are ignored
*/
val marketId: String? = null,
)
NoteYou can't provide anonymous user attributes with phone or/and email. For that purpose use
setUserAttributes()method with externalUserId
Multi-account support
Since 2.8.0 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, always use setMultiAccountUserAttributes instead of setUserAttributes.
Reteno.instance.setMultiAccountUserAttributes(externalUserId: String, user: User?)Reteno.getInstance().setMultiAccountUserAttributes(String externalUserId, User user);If you want to switch back to default behavior, just replace usages of setMultiAccountUserAttributes to setUserAttributes, this will rollback 1 token per device behavior.
NoteThe mobile API is asynchronous, so removing a push token on logout isn't instant. In practice this takes a few seconds, though it can lag further under heavier load.
