> ## 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.

# UserAttributes

> Structured user attributes for targeting and analytics

A structured 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

```tsx theme={null}
interface UserAttributes {
  // Identity & Basic Info
  email?: string;
  firstName?: string;
  lastName?: string;
  phoneNumber?: string;

  // Location
  postalCode?: string;
  city?: string;
  state?: string;
  countryCode?: string;
  latitude?: string;
  longitude?: string;

  // Demographics
  dateOfBirth?: string;
  gender?: string;
  language?: string;

  // Subscription & Billing
  subscriptionTier?: string;
  monthsSubscribed?: string;
  billingCycle?: string;
  lastPaymentAmount?: string;

  // Engagement
  lastActiveDate?: string;
  totalSessions?: string;

  // Custom Attributes
  custom?: Record<string, string>;
}
```

## Field Reference

### Identity & 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`    | Phone number         |

### Location

| Field         | Type    | Format             | Example         | Description          |
| ------------- | ------- | ------------------ | --------------- | -------------------- |
| `postalCode`  | string? | postal/ZIP code    | `SW1A 1AA`      | Postal 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        |
| ------------- | ------- | ---------------- | ------------ | ------------------ |
| `dateOfBirth` | string? | ISO 8601 date    | `1990-05-21` | Date of birth      |
| `gender`      | string? | free-form string | `female`     | Gender             |
| `language`    | string? | ISO 639-1        | `en`         | Preferred language |

### Subscription & Billing

| Field               | Type    | Format            | Example                  | Description               |
| ------------------- | ------- | ----------------- | ------------------------ | ------------------------- |
| `subscriptionTier`  | string? | plan name         | `free`, `premium`, `pro` | Current subscription tier |
| `monthsSubscribed`  | string? | integer string    | `6`                      | Months subscribed         |
| `billingCycle`      | string? | enum string       | `monthly`, `annual`      | Billing frequency         |
| `lastPaymentAmount` | string? | decimal as string | `9.99`                   | Last payment amount       |

### Engagement

| Field            | Type    | Format            | Example                | Description             |
| ---------------- | ------- | ----------------- | ---------------------- | ----------------------- |
| `lastActiveDate` | string? | ISO 8601 datetime | `2024-03-15T14:30:00Z` | Last activity timestamp |
| `totalSessions`  | string? | integer string    | `42`                   | Total sessions          |

### Custom Attributes

| Field    | Type                     | Format          | Example                 | Description                  |
| -------- | ------------------------ | --------------- | ----------------------- | ---------------------------- |
| `custom` | `Record<string, string>` | key-value pairs | `{ churnRisk: 'high' }` | Additional custom attributes |

## Usage

```tsx theme={null}
await Encore.setUserAttributes({
  email: 'user@example.com',
  subscriptionTier: 'premium',
  monthsSubscribed: '6',
});
```
