> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wendung.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Wendung.identify(): Associate all events with a user

> Associate a user ID and optional traits with all subsequent events. Call after login or whenever the current user's identity becomes known to your app.

Call `Wendung.identify()` after a user logs in or whenever their identity becomes available. Every event tracked afterwards carries the provided `userId` and `traits`. Each call replaces the previous identity wholesale; traits are not merged. Events snapshot the identity at the moment `step()` is called, so events already queued keep the identity they were tracked with.

Throws if called before [`init()`](/api-reference/init).

```typescript theme={null}
Wendung.identify(userId: string, traits?: Record<string, unknown>): void
```

## Parameters

<ParamField body="userId" type="string" required>
  A unique, stable identifier for the user, such as a database primary key or UUID. Sent in every subsequent event payload as `identity.userId`.
</ParamField>

<ParamField body="traits" type="Record<string, unknown>">
  Optional key-value metadata describing the user, for example `email`, `name`, or `plan`. Deep-cloned at call time. Replaces any previously set traits entirely, so include every trait you want to keep. Defaults to `{}`.
</ParamField>

## Returns

`void`

## Examples

### After login

```typescript theme={null}
Wendung.identify('usr_01HXYZ', {
  email: 'ada@example.com',
  name: 'Ada Lovelace',
  plan: 'pro',
})
```

### Updating traits on plan change

Because `identify()` replaces traits rather than merging them, spread the existing traits when updating one:

```typescript theme={null}
Wendung.identify(currentUser.id, {
  ...currentUser.traits,
  plan: 'enterprise',
})
```

<Note>
  Traits are sent to your ingest endpoint as-is. Avoid including sensitive values such as passwords or payment card numbers.
</Note>

<Tip>
  Call [`reset()`](/api-reference/reset) on logout so later events are not attributed to the previous user.
</Tip>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.