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

# Identify Users

> Learn how to identify users and set user properties

## Overview

This step introduces the `identify` method, which allows you to see which users triggered each event in Mixpanel.

It also introduces the `people.set` method, which allows you to define the attributes of each user.

## Why Identify Users?

Identifying users allows you to:

* Track user journeys across sessions and devices
* Analyze behavior by user cohorts
* View individual user profiles
* Send targeted messages based on user properties

## Code Examples

Replace `USER_ID` with a unique identifier, preferably the user ID from your database.

Including the user's email is also suggested, along with any additional **User Properties** such as name, avatar, created date, etc.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    mixpanel.identify('USER_ID')

    mixpanel.people.set({ 
      '$name': 'Jane Doe',
      '$email': 'jane.doe@example.com',
      'plan': 'Premium'
      // Add anything else about the user here
    });
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    mp.people_set('USER_ID', {
      '$name': 'Jane Doe',
      '$email': 'jane.doe@example.com',
      'plan': 'Premium'
      # Add anything else about the user here
    })
    ```

    <Info>
      You may want to disable ip geolocation when using a server-side SDK. You can learn more in [Server-Side Best Practices](/docs/tracking-best-practices/server-side-best-practices)
    </Info>
  </Tab>

  <Tab title="PHP">
    ```php theme={null}
    // create/update a profile for user id 12345
    $mp->people->set('USER_ID', array(
        '$name' => "John Doe",
        '$email' => "john.doe@example.com",
        '$phone' => "5555555555",
        "Favorite Color" => "red"
    ));
    ```

    <Info>
      You may want to disable ip geolocation when using a server-side SDK. You can learn more in [Server-Side Best Practices](/docs/tracking-best-practices/server-side-best-practices)
    </Info>
  </Tab>

  <Tab title="Node.js">
    ```javascript theme={null}
    mixpanel.people.set('USER_ID', {
        $name: 'Jane Doe',
        $email: 'jane.doe@example.com',
        plan: 'premium'
        // Add anything else about the user here
    });
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    exampleUser := mp.NewPeopleProperties("USER_ID", map[string]any{
      "$name": "Jane Doe",
      "$email": "jane.doe@example.com",
      "plan": "Premium"
      // Add anything else about the user here
    })

    err := mp.PeopleSet(ctx, []*mixpanel.PeopleProperties{
      exampleUser,
    })
    ```

    <Info>
      You may want to disable ip geolocation when using a server-side SDK. You can learn more in [Server-Side Best Practices](/docs/tracking-best-practices/server-side-best-practices)
    </Info>
  </Tab>

  <Tab title="Ruby">
    ```ruby theme={null}
    mp.people.set('USER_ID', {
        '$name' => 'Jane Doe',
        '$email' => 'jane.doe@example.com',
        'plan' => 'Premium'
        # Add anything else about the user here
    });
    ```

    <Info>
      You may want to disable ip geolocation when using a server-side SDK. You can learn more in [Server-Side Best Practices](/docs/tracking-best-practices/server-side-best-practices)
    </Info>
  </Tab>

  <Tab title="Java">
    ```java theme={null}
    JSONObject props = new JSONObject();
    props.put("$name", "Jane Doe");
    props.put("$email", "jane.doe@example.com");
    props.put("plan", "Premium");
    JSONObject update = messageBuilder.set("USER_ID", props);

    // Send the update to mixpanel
    mixpanel.sendMessage(update);
    ```
  </Tab>

  <Tab title="React Native">
    ```javascript theme={null}
    mixpanel.identify("USER_ID");

    // Identify must be called before properties are set
    mixpanel.getPeople().set("$name", "Jane Doe");
    mixpanel.getPeople().set("$email", "jane.doe@example.com");
    mixpanel.getPeople().set("plan", "Premium");
    ```

    <Info>
      You may want to disable ip geolocation when using a server-side SDK. You can learn more in [Server-Side Best Practices](/docs/tracking-best-practices/server-side-best-practices)
    </Info>
  </Tab>

  <Tab title="Flutter">
    ```dart theme={null}
    mixpanel.identify("USER_ID");

    // Identify must be called before properties are set
    mixpanel.getPeople().set("\$name", "Jane Doe");
    mixpanel.getPeople().set("\$email", "jane.doe@example.com");
    mixpanel.getPeople().set("plan", "Premium");
    ```
  </Tab>

  <Tab title="iOS Objective-C">
    ```objc theme={null}
    [mixpanel identify:@"USER_ID"];

    [mixpanel.people set:@{@"$name": @"Jane Doe"}];
    [mixpanel.people set:@{@"$email": @"jane.deo@example.com"}];
    [mixpanel.people set:@{@"plan": @"Premium"}];
    ```
  </Tab>

  <Tab title="iOS Swift">
    ```swift theme={null}
    Mixpanel.mainInstance().identify(distinctId: "USER_ID")

    Mixpanel.mainInstance().people.set(properties: [ 
      "$name": "Jane Doe",
      "$email": "jane.doe@example.com",
      "$plan": "Premium"
    ])
    ```
  </Tab>

  <Tab title="Android">
    ```java theme={null}
    // The second param is a flag for allowing profile updates
    mp.identify("USER_ID", true);

    // Identify must be called before properties are set
    mp.getPeople().set("$name", "Jane Doe");
    mp.getPeople().set("$email", "jane.doe@example.com");
    mp.getPeople().set("plan", "Premium");
    ```
  </Tab>

  <Tab title="Unity">
    ```csharp theme={null}
    Mixpanel.Identify("USER_ID");

    // Identify must be called before properties are set
    Mixpanel.People.Set("$name", "Jane Doe");
    Mixpanel.People.Set("$email", "jane.doe@example.com");
    Mixpanel.People.Set("plan", "Premium");
    ```
  </Tab>
</Tabs>

<Success>
  Congratulations, you've tracked your first user! You can see them in Mixpanel via the [Users page](https://mixpanel.com/report/users).
</Success>

## Next Steps

Once you've implemented `identify`, it's time to track what your users are doing in your product.

<Card title="Capture Events" icon="chart-line" href="/quickstart/capture-events">
  Learn how to track user actions and behaviors
</Card>

## FAQ

<AccordionGroup>
  <Accordion title="How do I connect events from logged-out to logged-in users?">
    If tracking client-side, just call `.identify(<user_id>)` when a user logs in and `.reset()` when they log out. Mixpanel will automatically stitch the user journey across logged out and logged in.

    If tracking server-side, check out our [server-side best practices guide](/docs/best-practices/server-side-best-practices). For more information, read our comprehensive guide on [Identifying Users](/docs/tracking-methods/id-management/identifying-users).
  </Accordion>

  <Accordion title="What does Mixpanel track automatically?">
    Mixpanel's Data Ingestion APIs and Client-Side SDKs automatically collect certain properties on every event or user profile update. Examples include: location, operating system, device, etc. Mixpanel calls this auto-generated data "Default Properties".

    [Learn More About Default Properties](/docs/data-structure/property-reference#default-properties)
  </Accordion>

  <Accordion title="How can I track in a privacy compliant way?">
    If a user opts out of tracking, you can call the `.optOutTracking()` method on any of our client-side SDKs; this prevents any subsequent data being tracked from that user's device. Learn more [here](/docs/privacy/protecting-user-data).

    For iOS specifically: Mixpanel does not use IDFA, so it does not require user permission through the AppTrackingTransparency(ATT) framework. For more details, refer to our [Apple App Developer Privacy Guidance](https://mixpanel.com/legal/app-store-privacy-details).
  </Accordion>
</AccordionGroup>
