Structure
data class UserAttributes(
val email: String? = null,
val firstName: String? = null,
val lastName: String? = null,
val phoneNumber: String? = null,
val postalCode: String? = null,
val city: String? = null,
val state: String? = null,
val countryCode: String? = null,
val latitude: String? = null,
val longitude: String? = null,
val dateOfBirth: String? = null,
val gender: String? = null,
val language: String? = null,
val subscriptionTier: String? = null,
val monthsSubscribed: String? = null,
val billingCycle: String? = null,
val lastPaymentAmount: String? = null,
val lastActiveDate: String? = null,
val totalSessions: String? = null,
val custom: Map<String, String> = emptyMap(),
// Last in the constructor: pass it by name, as `age = 25`.
val age: Int? = null,
)
Field reference
Identity and basic info
| Field | Type | Format | Example | Description |
|---|---|---|---|---|
email | String? | email address | user@example.com | User’s email address |
firstName | String? | free-form string | Jane | User’s first name |
lastName | String? | free-form string | Doe | User’s last name |
phoneNumber | String? | E.164 or local | +442071838750 | User’s phone number |
Location
| Field | Type | Format | Example | Description |
|---|---|---|---|---|
postalCode | String? | postal/ZIP code | SW1A 1AA | Postal or ZIP code |
city | String? | free-form string | San Francisco | City name |
state | String? | abbr or full | CA | State/province |
countryCode | String? | ISO 3166-1 alpha-2 | US | Country code |
latitude | String? | decimal degrees | 37.7749 | Geographic latitude |
longitude | String? | decimal degrees | -122.4194 | Geographic longitude |
Demographics
| Field | Type | Format | Example | Description |
|---|---|---|---|---|
age | Int? | whole years, 0 to 120 | 25 | The user’s age. Send the lowest end of a range. A user under 18 is served age-appropriate offers with no per-user personalization. Not saved between launches: pass dateOfBirth, or set age on every launch |
dateOfBirth | String? | YYYY-MM-DD | 2001-04-18 | The user’s date of birth. The SDK works the age out from it on the device and never sends the date. Given age too, the lower age is used. An unreadable or future date gives no age |
gender | String? | free-form string | female | User’s gender. Accepted only from an app rated 18+ in its store listing |
language | String? | BCP-47 tag | es, es-MX | Deprecated. Use setLanguage() instead. From the release that adds setLanguage(), setting this field calls it for you and logs a warning once. Removed at the next major release. See Localization |
Subscription and billing
| Field | Type | Format | Example | Description |
|---|---|---|---|---|
subscriptionTier | String? | plan name | free, premium, pro | Current subscription plan/tier |
monthsSubscribed | String? | integer string | 6 | Number of months subscribed |
billingCycle | String? | enum string | monthly, annual | Billing frequency |
lastPaymentAmount | String? | decimal as string | 9.99 | Amount of last payment |
Engagement
| Field | Type | Format | Example | Description |
|---|---|---|---|---|
lastActiveDate | String? | ISO 8601 datetime | 2024-03-15T14:30:00Z | Timestamp of last activity |
totalSessions | String? | integer string | 42 | Total number of sessions |
Custom attributes
| Field | Type | Format | Example | Description |
|---|---|---|---|---|
custom | Map<String, String> | key-value pairs | mapOf("churnRisk" to "high") | Any additional attributes not covered above |
Usage
val attributes = UserAttributes(
email = "user@example.com",
subscriptionTier = "premium",
monthsSubscribed = "6"
)
Encore.shared.setUserAttributes(attributes)
Related
- setUserAttributes(): merges these attributes into the current user’s profile
- identify(): accepts the same attributes alongside your user ID