> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encorekit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# EncoreUserAttributes

> Every field of EncoreUserAttributes with its type, format, and an example value

A class for storing user metadata used in offer targeting, personalization, and analytics. It carries the same fields as the native `UserAttributes` type on [iOS](/publishers/ios/sdk-reference/user-attributes) and [Android](/publishers/android/sdk-reference/user-attributes), and the plugin passes each one through to the native SDK unchanged.

All fields are optional: pass only what you have.

## Structure

```dart theme={null}
class EncoreUserAttributes {
  // Identity and basic info
  final String? email;
  final String? firstName;
  final String? lastName;
  final String? phoneNumber;

  // Location
  final String? postalCode;
  final String? city;
  final String? state;
  final String? countryCode;
  final String? latitude;
  final String? longitude;

  // Demographics
  final String? dateOfBirth;
  final String? gender;
  final String? language;

  // Subscription and billing
  final String? subscriptionTier;
  final String? monthsSubscribed;
  final String? billingCycle;
  final String? lastPaymentAmount;

  // Engagement
  final String? lastActiveDate;
  final String? totalSessions;

  // Custom attributes
  final Map<String, String> custom;

  const EncoreUserAttributes({
    this.email,
    this.firstName,
    this.lastName,
    this.phoneNumber,
    this.postalCode,
    this.city,
    this.state,
    this.countryCode,
    this.latitude,
    this.longitude,
    this.dateOfBirth,
    this.gender,
    this.language,
    this.subscriptionTier,
    this.monthsSubscribed,
    this.billingCycle,
    this.lastPaymentAmount,
    this.lastActiveDate,
    this.totalSessions,
    this.custom = const {},
  });
}
```

Every value is a `String`, including numbers and dates. Convert before you pass them, for example `months.toString()`.

## 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, with country code for international numbers | `+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 or province    |
| `countryCode` | `String?` | ISO 3166-1 alpha-2, uppercase | `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                                                                       |
| ------------- | --------- | ---------------------------- | ------------ | --------------------------------------------------------------------------------- |
| `dateOfBirth` | `String?` | ISO 8601 date (`YYYY-MM-DD`) | `1990-05-21` | User's date of birth                                                              |
| `gender`      | `String?` | free-form string             | `female`     | User's gender. Common values: `male`, `female`, `non-binary`, `prefer_not_to_say` |
| `language`    | `String?` | ISO 639-1                    | `en`         | Preferred language                                                                |

### Subscription and billing

| Field               | Type      | Format            | Example                  | Description                       |
| ------------------- | --------- | ----------------- | ------------------------ | --------------------------------- |
| `subscriptionTier`  | `String?` | plan name         | `free`, `premium`, `pro` | Current subscription plan or 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 app sessions |

### Custom attributes

| Field    | Type                  | Format          | Example                 | Description                                                           |
| -------- | --------------------- | --------------- | ----------------------- | --------------------------------------------------------------------- |
| `custom` | `Map<String, String>` | key-value pairs | `{'churnRisk': 'high'}` | Any additional attributes not covered above. Defaults to an empty map |

## Usage

```dart theme={null}
await Encore.shared.setUserAttributes(
  EncoreUserAttributes(
    email: 'user@example.com',
    countryCode: 'US',
    language: 'en',
    dateOfBirth: '1990-05-21',
    subscriptionTier: 'premium',
    monthsSubscribed: '6',
    custom: {'favoritePosition': 'point_guard'},
  ),
);
```

[`setUserAttributes()`](./set-user-attributes) merges these into the stored set; [`identify()`](./identify) replaces it; [`reset()`](./reset) clears it.

## Related

* [setUserAttributes()](./set-user-attributes): merges these attributes into the current user's profile
* [identify()](./identify): accepts the same attributes alongside your user ID
* [UserAttributes on iOS](/publishers/ios/sdk-reference/user-attributes): the native type these fields map to
