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

# User Management

> Identifying users, setting attributes, and managing identity in your Flutter app.

## Overview

Encore requires user identification to track entitlements and prevent abuse across devices. You can also set user attributes to enable targeted offers and personalization.

***

## Anonymous Users

Encore **automatically generates** a random user ID that persists until the user deletes/reinstalls your app or calls `reset()`.

This anonymous ID is stored securely on the native side and allows entitlement tracking to work immediately without requiring explicit user identification.

***

## Identified Users

If you use your own user management system, call `identify` when you have a user's identity:

```dart theme={null}
await Encore.shared.identify(userId: user.id);
```

This enables the SDK to:

* Associate promotional access with your user account
* Sync entitlements across devices when the user logs in
* Track conversion attribution accurately

***

## Setting User Attributes

User attributes enable personalized offers, audience targeting, and conversion context tracking.

Set attributes using the `EncoreUserAttributes` class. All values are strings; use the `custom` map for app-specific fields:

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

You can also set attributes when identifying:

```dart theme={null}
await Encore.shared.identify(
  userId: 'user_12345',
  attributes: EncoreUserAttributes(
    email: 'user@example.com',
    subscriptionTier: 'premium',
  ),
);
```

<Tip>
  `setUserAttributes()` **merges** with existing attributes — it does not replace them.
</Tip>

***

## Resetting User Identity

When a user logs out, call `reset()`:

```dart theme={null}
await Encore.shared.reset();
```

This will:

* Reset the user ID to a new auto-generated anonymous ID
* Clear cached entitlement data
* Clear all user attributes

***

## Full Example

```dart theme={null}
import 'package:flutter/material.dart';
import 'package:encore_flutter/encore_flutter.dart';

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    _initEncore();
  }

  Future<void> _initEncore() async {
    await Encore.shared.configure(apiKey: 'pk_your_api_key');

    // If the user is already logged in
    if (authManager.isAuthenticated) {
      await Encore.shared.identify(
        userId: authManager.userId,
        attributes: EncoreUserAttributes(
          email: authManager.email,
          subscriptionTier: authManager.tier,
        ),
      );
    }
  }

  void _onLogout() async {
    await Encore.shared.reset();
    authManager.logout();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: HomeScreen(onLogout: _onLogout));
  }
}
```

***

## Apps Without Login

If your app doesn't require users to log in, you don't need to call `identify`. The SDK uses an auto-generated anonymous ID. You can still set attributes:

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

await Encore.placement('cancel_flow').show();
```

***

## Next Steps

* **[Present Offers](./present-offers)** — Show promotional offers and handle purchase results
* **[Add Subscription Product](./add-subscription-product)** — Create a subscription product and connect it to Encore
