# Identify users

Identifying users enables you to build the full picture of how a person uses your product across different sessions and devices.

Collecting user properties also is crucial for running Workflows and Segmentation where you want to send emails, personalise copy, and target users better.

To identify a user, call the `identify` method:

{% tabs %}
{% tab title="Web SDK" %}

```javascript
import UserFlux from '@userflux/browser-js'

await UserFlux.identify({
    properties: { email: 'johndoe@gmail.com', name: 'John' },
    userId: '<USER_ID>' // replace <USER_ID> with your user's unique identifier
})
```

{% endtab %}

{% tab title="React SDK" %}

```javascript
import { useUserFlux } from "@userflux/browser-js-react"

const userFlux = useUserFlux()

await userFlux.identify({
    properties: { email: 'johndoe@gmail.com', name: 'John' },
    userId: '<USER_ID>' // // replace <USER_ID> with your user's unique identifier
})
```

{% endtab %}

{% tab title="Backend JS SDK" %}

```javascript
ufClient.identify({
    properties: { email: 'johndoe@gmail.com', name: 'John' },
    userId: '<USER_ID>' // // replace <USER_ID> with your user's unique identifier
});
```

{% endtab %}

{% tab title="API" %}
{% content-ref url="/pages/DtbzigZ9ONFjSrsXs0RN" %}
[Profiles API](/userflux-docs/apis/profiles-api.md)
{% endcontent-ref %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
When setting up user properties, you must use the exact field name "email" for the user's email address. Do not use variations like "email\_address" or other alternatives, as these will not work with marketing automation features.
{% endhint %}

***

## How identify works

In UserFlux, there are two types of users: **Known** and **Anonymous**.

If you have not identified a user yet but are tracking their traffic on your website, this will automatically create an Anonymous user unique to that device.

Identifying a user with a user ID allows you to build up your user base, collect information about your users, as well as stitch any Anonymous users to their associated Known user profile.

#### Linking

Known and Anonymous users are a one-to-many relationship. That is, one Known user can be linked to many Anonymous users.

When you call identify with a user ID, UserFlux will associate the auto-generated Anonymous user to the Known user.

#### Merging properties

When an Anonymous user is linked to a Known user for the first time, or when an existing linked Anonymous users properties are updated, that information will be merged with the primary Known user profile.

This means the Known user profile will have the most up to date information on any:

* Properties defined by you
* Device information
* Location information

#### Computed Properties

Computed Properties are only calculated for Known users, however when evaluating the Computed Property, UserFlux will take in to account any linked Anonymous user data.

This is useful when using Computed Properties for things such as event roll ups, where you want to aggregate behavioural data from a user.

#### Workflow Checks

Having users linked to their Anonymous users is also a helpful data point when crafting user Workflow's.

For example, a classic Workflow for an ecommerce site would be an Abandoned Cart Email. If a anonymous website viewer has previously been linked to a known account, the next time they start a checkout but don't provide any contact details, you will still be able to send them a follow up email.

***

## Best practices

#### Identify users as soon as possible

You should set a user ID once they have created an account, logged in, or is otherwise identified in your product.

#### Set user properties as soon as you collect the information

Whenever you receive new data from a user, such as age, email, mobile number, you should call `identify` with this information as soon as possible.

#### Use unique strings for user IDs

If two users have the same user ID, their data is merged and they are considered one user in UserFlux.

#### User IDs are case-sensitive

If you set a user ID in a different case, UserFlux tracks two separate profiles for the same user.

#### Don't set the user ID if there isn't one

For example, if you set the user ID to the string `None` for multiple users, UserFlux doesn't recognize those users as separate users. Instead, it assumes all those users are actually the **same** user, and it groups all events for those users together under that `None` user ID.&#x20;

You can always set the user ID later.

#### Don't assign a user ID that might change

User IDs are fixed forever: you shouldn't, for example, set a user's email address as their user ID—email addresses change.

#### Reset after logout

If a user logs out on your frontend, you should call `reset()` to unlink any future events made on that device with that user.

This is important if your users are sharing a computer, as otherwise all of those users are grouped together into a single user due to shared cookies between sessions.

```javascript
await UserFlux.reset()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://userflux.gitbook.io/userflux-docs/integration/identify-users.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
