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

# Identify users

> Link anonymous visitors to known users after signup or login, set traits, and reset identity on logout.

By default, each browser is an anonymous visitor with a persistent `anonymous_id`. When a user signs up or logs in, call `identify()` to link the browser to your own user ID. Their earlier anonymous activity then joins their profile.

## Step 1: Choose a user ID

Use a **stable ID from your own app**, such as your database user ID. Do not use an email address as the ID: emails change, and an email can be a trait instead.

## Step 2: Call identify after login

```ts theme={null}
await analytics.identify('user_123', {
  email: 'user@example.com',
  plan: 'pro',
});
```

`identify()` sends an `identify` event with the `user_id` and the traits. The SDK stores the user ID in a first-party browser-session cookie and adds it to later events. Events from before `identify()` have the same `anonymous_id`, so they link to the user.

With the HTML snippet, use `window.untitledAnalytics.identify(...)`.

> [!TIP]
>
> Call `identify()` on every login and on page load when a user is already signed in. It is safe to call it again with the same ID.

## Step 3: Update traits

Traits are scalar values: string (up to 1024 characters), number, boolean or `null`. A later call updates only the keys it sends:

```ts theme={null}
// Changes plan, keeps email.
await analytics.identify('user_123', { plan: 'enterprise' });

// Clears the plan trait.
await analytics.identify('user_123', { plan: null });
```

A work email also sets a `company_domain` hint. Common personal email providers are excluded.

You can also add or change traits on the user's profile page under **Customer properties**.

## Step 4: Reset on logout

```ts theme={null}
analytics.reset();
```

`reset()` clears the user ID, the anonymous ID and the session from every storage layer. The next event starts a new anonymous visitor. Stored history is not deleted.

## Identify from your backend

When the user ID is known only on the server, send an `identify` [server event](https://docs.manalens.dev/sdks/server.md) with the [Secret key](https://docs.manalens.dev/api/authentication.md#secret-key). Include the browser's `anonymous_id` (from `analytics.getAnonymousId()`) to link that browser to the user.

## One player on the website and in the game

A player has one anonymous ID in each browser and one in each game install. Reports join them into one user in two ways:

* **The same user ID:** the website and the game both call `identify()` with the same user ID.
* **A link from the game:** the game opens your website with the Godot SDK's [`link_url()`](https://docs.manalens.dev/sdks/godot#open-your-website-from-the-game). This works for players who never sign in.

A user counts once in Users, profiles, funnels, retention, lifecycle, goals, attribution and revenue by source. Overview visitor counts stay one per browser or install.

Rules for a link from the game:

* The link works for 10 minutes. An older link joins nothing.
* If links from one game install open in more than 3 browsers, the link was shared, and none of them join.
* If one browser opens links from two or more game installs, it joins none of them.
* If the joined IDs have two different user IDs, no user is given to the anonymous activity.

> [!NOTE]
>
> The 10-minute limit uses the time in the link, so it stops a shared link in a normal browser. Someone who builds the request by hand and knows a game's anonymous ID can still join their own browser to that player in your reports. The game ID is only in links that the player opens. This affects analytics data only.

## Shared browsers

If several users sign in on one browser, that browser's anonymous events stay unassigned. They are not given to the last user. Each user's own identified events are still theirs.

## Link billing records

To link Stripe or Paddle revenue to a user, add the customer ID as a trait:

```ts theme={null}
await analytics.identify('user_123', { stripe_customer_id: 'cus_123' });
```

See [revenue](https://docs.manalens.dev/features/revenue.md#link-revenue-to-users).


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