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

> How the Encore Web SDK handles identity: an auto-generated anonymous UUID persisted in localStorage, identify() to attach your own stable user id, setUserAttributes() for targeting, and reset() on logout.

## Anonymous users

You don't have to provide a user id. On `configure()`, the SDK **auto-generates** a UUID and
persists it in `localStorage` (falling back to `sessionStorage`, then memory), so the same
visitor keeps the same id across reloads until they clear browser data or you call `reset()`.

```javascript theme={null}
import Encore from '@encorekit/web-sdk';

Encore.configure({ apiKey: 'pk_live_yourpublishablekey' });

Encore.getCurrentUserId(); // e.g. "550e8400-e29b-41d4-a716-446655440000"
```

## Identify users

When you know who the user is (after login, signup, or session restore), attach your own
stable id, optionally with attributes in the same call:

```javascript theme={null}
Encore.identify('user-123', {
  email: 'user@example.com',
  subscriptionTier: 'free',
});
```

Call `identify()` **as early as you reliably can**, and use the same id across sessions and
devices. Claims, subscription events, and measurement all join on this id (the SDK's
*app account id*, also readable via `Encore.getAppAccountId()`), so a stable id keeps a
returning user's history in one place. `localStorage` is per-origin and per-browser; only
your own id survives a device switch.

See [`identify()`](/publishers/web/sdk-reference/identify) for the full contract.

## User attributes

Attributes power offer targeting and personalization. They **merge** with existing
attributes, so set them incrementally as you learn more about the user:

```javascript theme={null}
Encore.setUserAttributes({
  email: 'user@example.com',
  subscriptionTier: 'premium',
  city: 'San Francisco',
  countryCode: 'US',
  custom: {
    accountType: 'business',   // any app-specific string key/values
  },
});

Encore.getUserAttributes(); // read back the merged set
```

The supported keys (all optional strings, plus a free-form
`custom: Record<string, string>`) are listed field-by-field in
[`setUserAttributes()`](/publishers/web/sdk-reference/set-user-attributes).

## Reset on logout

`reset()` clears all locally stored SDK state (identity, attributes, queued signals, and
any pending unredeemed claim) and generates a fresh anonymous UUID:

```javascript theme={null}
function handleLogout() {
  clearAppSession();  // your own session teardown
  Encore.reset();
}
```

Call it on logout and when switching accounts (then `identify()` the new user). See
[`reset()`](/publishers/web/sdk-reference/reset).

## Complete flow

```javascript theme={null}
import Encore from '@encorekit/web-sdk';

// App startup: anonymous id is auto-generated
Encore.configure({ apiKey: 'pk_live_yourpublishablekey' });

// After login/signup
Encore.identify(user.id, { email: user.email, subscriptionTier: user.tier });

// As the profile evolves
Encore.setUserAttributes({ subscriptionTier: 'premium', billingCycle: 'annual' });

// On logout
Encore.reset();
```

## Next steps

* **[Present Offers](./present-offers)**: show offers and handle the result
* **[SDK Reference](/publishers/web/sdk-reference/overview)**: full API contracts
