> ## 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()

> Merge structured attributes into the current user's profile for targeting and analytics

Stores structured attributes for the current user to power offer targeting, personalization, and analytics. Attributes are **merged** with the ones already stored; they do not replace them.

## Signature

```dart theme={null}
Future<void> setUserAttributes(EncoreUserAttributes attributes)
```

The `Future` completes once the call reaches the native SDK. It does not wait for the network.

## Parameters

| Name         | Type                                        | Description                                                                            |
| ------------ | ------------------------------------------- | -------------------------------------------------------------------------------------- |
| `attributes` | [`EncoreUserAttributes`](./user-attributes) | The attributes to merge. See [EncoreUserAttributes](./user-attributes) for every field |

## Merge rules

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

* **A field you leave `null` is unchanged.** Passing only `language` updates `language` and nothing else.
* **`custom` merges key by key.** A key you send overwrites the stored value for that key; keys you don't send are kept.
* **You can't clear a single field.** `null` means "leave as is". To clear everything, call [`reset()`](./reset).
* **An empty `EncoreUserAttributes()` does nothing.**

[`identify()`](./identify) behaves differently: attributes passed there replace the stored set.

## Usage

### Basic attributes

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

### Custom attributes

```dart theme={null}
await Encore.shared.setUserAttributes(
  EncoreUserAttributes(custom: {'cancelReason': 'too_expensive'}),
);
```

### Location and language

```dart theme={null}
await Encore.shared.setUserAttributes(
  EncoreUserAttributes(countryCode: 'US', language: 'en'),
);
```

<Note>
  Call `setUserAttributes()` after [`configure()`](./configure). Attributes set before the SDK is configured are not stored.
</Note>

## Related

* [EncoreUserAttributes](./user-attributes): every field, its format, and an example value
* [identify()](./identify): sets a user ID and attributes in one call
