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

# User identity

The Gleap identify call lets you tie a user to their feedback items. It includes a unique User ID and optional meta information such as email & name.

### Identify your users

To effectively manage your contacts, we advise using `identifyContact` each time a user signs in or registers. This practice ensures accurate identification of your contacts from the outset. Additionally, for scenarios where contact information needs to be updated during active usage – such as when a user subscribes to a new plan or modifies their existing data – we recommend utilizing `updateContact`. This method allows for seamless real-time updates to contact details.

Identify your user by calling the following method.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let userProperty = GleapUserProperty()
    userProperty.name = "Franz"
    userProperty.email = "franz@gleap.io"
    userProperty.phone = "+1 (902) 123123"
    userProperty.value = 199.95
    userProperty.plan = "Pro plan";
    userProperty.companyId = "29883";
    userProperty.companyName = "ACME inc.";
    userProperty.customData = ["key1": "Custom data"];

    Gleap.identifyContact("user_1234", andData: userProperty)
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    GleapUserProperty *userProperty = [[GleapUserProperty alloc] init];
    userProperty.name = @"Franz";
    userProperty.email = @"franz@gleap.io";
    userProperty.phone = @"+1 (902) 123123";
    userProperty.value = @(199.95);
    userProperty.plan = @"Pro plan";
    userProperty.companyId = @"29883";
    userProperty.companyName = @"ACME inc.";
    userProperty.customData = @{
        @"key1": @"Custom data",
    };

    [Gleap identifyContact: @"user_1234" andData: userProperty];
    ```
  </Tab>
</Tabs>

<Info>
  When transmitting custom data, only primitive numeric and string values are supported for later use in segment filters.
  Please note that you can send only 35 custom data keys with an identify call.

  We currently only allow JSON strings, numbers and boolean values as custom data.
</Info>

<Info>
  Gleap defaults to guest sessions when feedback items get reported without
  calling the identify method first. All feedback items of an existing guest
  session are merged with the user session once you've identified it.
</Info>

### Enforce identity verification

Enforce identity verification to prevent third parties from impersonating logged-in users. [Learn how to generate the user hash](../guides/enforce-identity-verification)

```swift theme={null}
let userProperty = GleapUserProperty()
userProperty.name = "Franz"
userProperty.email = "franz@gleap.io"
userProperty.phone = "+1 (902) 123123"
userProperty.value = 199.95
userProperty.plan = "Pro plan"
userProperty.companyId = "29883"
userProperty.companyName = "ACME inc."
userProperty.customData = [
    "key1": "data",
]

Gleap.identifyContact("user_1234", andData: userProperty, andUserHash: "GENERATED_USER_HASH")
```

[Click here](../guides/enforce-identity-verification.mdx) to learn how to generate the user hash.

### Update contact properties

To effectively manage your contacts, we advise using `identifyContact` each time a user signs in or registers. This practice ensures accurate identification of your contacts from the outset. Additionally, for scenarios where contact information needs to be updated during active usage – such as when a user subscribes to a new plan or modifies their existing data – we recommend utilizing `updateContact`. This method allows for seamless real-time updates to contact details.

```javascript theme={null}
let userProperty = GleapUserProperty();
userProperty.value = 199.95;
userProperty.plan = "Pro plan";

Gleap.updateContact(userProperty);
```

The updateContact method takes in the same contact parameters as the identify method. Partial updates are possible.

```javascript theme={null}
let userProperty = GleapUserProperty()
userProperty.name = "Franz"
userProperty.email = "franz@gleap.io"
userProperty.phone = "+1 (902) 123123"
userProperty.value = 199.95
userProperty.plan = "Pro plan"
userProperty.companyId = "29883"
userProperty.companyName = "ACME inc."
userProperty.customData = [
    "key1": "data",
]

Gleap.updateContact(userProperty)
```

### Clear the identity on logout

We recommend to clear the identity once the user logs out. Clearing the identity will automatically detach the current session and create a new guest session.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    Gleap.clearIdentity();
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [Gleap clearIdentity];
    ```
  </Tab>
</Tabs>

### Get the identification status of a user

With the following method, you can get the status of the current user identity.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    Gleap.isUserIdentified();
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [Gleap isUserIdentified];
    ```
  </Tab>
</Tabs>

### Get the current user identity

With the following method, you can get the current user identity.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    Gleap.getIdentity();
    ```
  </Tab>

  <Tab title="Objective-C">
    ```objectivec theme={null}
    [Gleap getIdentity];
    ```
  </Tab>
</Tabs>
