Skip to main content
A data class for storing user metadata used in offer targeting, personalization, and analytics. All fields are optional and will be merged with existing attributes when set.

Structure

@JsonClass(generateAdapter = true)
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(),
)

Field Reference

Identity & Basic Info

FieldTypeFormatExampleDescription
emailString?email addressuser@example.comUser’s email address
firstNameString?free-form stringJaneUser’s first name
lastNameString?free-form stringDoeUser’s last name
phoneNumberString?E.164 or local+442071838750User’s phone number

Location

FieldTypeFormatExampleDescription
postalCodeString?postal/ZIP codeSW1A 1AAPostal or ZIP code
cityString?free-form stringSan FranciscoCity name
stateString?abbr or fullCAState/province
countryCodeString?ISO 3166-1 alpha-2USCountry code
latitudeString?decimal degrees37.7749Geographic latitude
longitudeString?decimal degrees-122.4194Geographic longitude

Demographics

FieldTypeFormatExampleDescription
dateOfBirthString?ISO 8601 date1990-05-21User’s date of birth
genderString?free-form stringfemaleUser’s gender
languageString?ISO 639-1enPreferred language

Subscription & Billing

FieldTypeFormatExampleDescription
subscriptionTierString?plan namefree, premium, proCurrent subscription plan/tier
monthsSubscribedString?integer string6Number of months subscribed
billingCycleString?enum stringmonthly, annualBilling frequency
lastPaymentAmountString?decimal as string9.99Amount of last payment

Engagement

FieldTypeFormatExampleDescription
lastActiveDateString?ISO 8601 datetime2024-03-15T14:30:00ZTimestamp of last activity
totalSessionsString?integer string42Total number of sessions

Custom Attributes

FieldTypeFormatExampleDescription
customMap<String, String>key-value pairsmapOf("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)