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

# setUserAttributes()

> Set custom attributes for targeting and analytics

Stores structured attributes for the current user to power offer targeting, personalization, and analytics. Attributes are **merged** with existing attributes—they do not replace them entirely.

## Signature

```swift theme={null}
public func setUserAttributes(
  _ attributes: UserAttributes
)
```

<Info>
  Attributes are **merged**, not replaced. If you set `email` and `subscriptionTier`, then later set `monthsSubscribed`, all three attributes will be preserved.
</Info>

## Parameters

| Name         | Type                                | Description                                                                                                                                          |
| ------------ | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `attributes` | [UserAttributes](./user-attributes) | Structured attributes object containing user metadata for targeting and analytics. See [UserAttributes](./user-attributes) for all available fields. |

## Usage

### Basic attributes

```swift theme={null}
Encore.shared.setUserAttributes(
  UserAttributes(
    email: "user@example.com",
    subscriptionTier: "premium",
    monthsSubscribed: "6"
  )
)
```
