Skip to main content
A structured data type 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

public struct EncoreAttributes {
  // Identity & Basic Info
  public let email: String?
  public let firstName: String?
  public let lastName: String?
  public let phoneNumber: String?
  
  // Location
  public let postalCode: String?
  public let city: String?
  public let state: String?
  public let countryCode: String?  
  public let latitude: String?     
  public let longitude: String?    
  
  // Demographics
  public let dateOfBirth: String?
  public let gender: String?
  public let language: String?
  
  // Subscription & Billing
  public let subscriptionTier: String?
  public let monthsSubscribed: String?
  public let billingCycle: String?
  public let lastPaymentAmount: String?
  
  // Engagement
  public let lastActiveDate: String?
  public let totalSessions: String?
  
  // In-App Purchase Integration
  public let iapProductId: String?
  
  // Custom Attributes
  public let custom: [String: String]
  
  public init(
    email: String? = nil,
    firstName: String? = nil,
    lastName: String? = nil,
    phoneNumber: String? = nil,
    postalCode: String? = nil,
    city: String? = nil,
    state: String? = nil,
    countryCode: String? = nil,
    latitude: String? = nil,
    longitude: String? = nil,
    dateOfBirth: String? = nil,
    gender: String? = nil,
    language: String? = nil,
    subscriptionTier: String? = nil,
    monthsSubscribed: String? = nil,
    billingCycle: String? = nil,
    lastPaymentAmount: String? = nil,
    lastActiveDate: String? = nil,
    totalSessions: String? = nil,
    iapProductId: String? = nil,
    custom: [String: String] = [:]
  )
}

Field Reference

Identity & Basic Info

FieldTypeFormatExampleDescription
emailString?email address[email protected]User’s email address
firstNameString?free-form stringJaneUser’s first name
lastNameString?free-form stringDoeUser’s last name
phoneNumberString?E.164 or local+442071838750Alternative phone number

Location

FieldTypeFormatExampleDescription
postalCodeString?postal/ZIP codeSW1A 1AAAlternative postal code key
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

In-App Purchase Integration

FieldTypeFormatExampleDescription
iapProductIdString?Apple IAP Product IDmonthly_premiumIf set, the SDK automatically presents Apple’s native subscription UI after an Encore offer is completed.
When iapProductId is configured, completing an Encore offer automatically triggers Apple’s IAP purchase flow. If the user subscribes, their IAP subscription grants access via your existing IAP manager—you don’t need to check Encore entitlements.

Custom Attributes

FieldTypeFormatExampleDescription
custom[String: String]JSON object (string:string){ "churnRisk": "high" }For any additional attributes not covered above

Usage

let attributes = EncoreAttributes(
  email: "[email protected]",
  subscriptionTier: "premium",
  monthsSubscribed: "6",
  iapProductId: "monthly_premium"  // Optional: Show Apple IAP after offer completion
)

Encore.shared.setUserAttributes(attributes)