# User Identifier & Properties

{% hint style="info" %}
User Identifier Management

User Identifiers are used to uniquely identify users. For the meaning and importance of User Identifiers and guidelines on how to choose them, refer to the [Managing User Identifiers](/en/getting-started/user-identifier.md) documentation.
{% endhint %}

## User Identifier

### Using Identifiers Managed by the SDK

The Unity SDK includes functionality to manage device identifiers. Therefore, users can be automatically identified even without providing a User Identifier separately.

You can retrieve the identifiers managed by the SDK as follows.

```csharp
Hackle hackle = Hackle.GetInstance();
// Get the device identifier managed internally
string deviceId = hackle.GetDeviceId();
```

### Add User Identifier

You can set the identifier for a logged-in user. If you manage the device identifier yourself, you can set it separately.

### Example

```csharp
Hackle hackle = Hackle.GetInstance();

// 1. Add logged-in user identifier
hackle.SetUserId("LOGIN_ID");

// 2. Change device identifier
hackle.SetDeviceId("CUSTOM_DEVICE_ID");
```

### Additional Identifiers

Additional identifiers beyond the default identifiers can be sent using the example code below.

```csharp
Hackle hackle = Hackle.GetInstance();

HackleUser user = new HackleUser.Builder()
    .UserId("LOGIN_ID") // User ID (Hackle ID compatible)
    .DeviceId("CUSTOM_DEVICE_ID") // Device ID (Hackle ID compatible)
    .Identifier("myCustomId", "CUSTOM_IDENTIFIER") // Custom ID
    .Build();

hackle.SetUser(user);
```

***

## User Property

The Hackle SDK supports adding User Properties.

* A property must be sent as a key-value pair consisting of a Property Key and a Property Value.
* You can add a maximum of 64 properties per user object.

<table><thead><tr><th width="133.04296875">Category</th><th width="127.60546875">Type</th><th>Constraints</th></tr></thead><tbody><tr><td>Property Key</td><td><code>string</code></td><td><ul><li>Character limit is 128 characters.</li><li>Case-insensitive.</li><li>For example, AGE and age are recognized as the same Property Key.</li></ul></td></tr><tr><td>Property Value</td><td><code>boolean</code>, <code>string</code>, <code>number</code>, <code>array</code></td><td><ul><li>For string type, the character limit is 1024 characters.</li><li>String type is case-sensitive.</li><li>For example, APPLE and apple are recognized as different Property Values.</li><li>For number type, up to 15 integer digits and up to 6 decimal places are supported.</li></ul></td></tr></tbody></table>

### Configure User Properties

You can add or remove User Properties.

Instantiate a `PropertyOperations` object with the User Properties you want to configure. Then call `UpdateUserProperties` to update the User Properties. You can configure multiple properties at once.

```csharp
PropertyOperations operations = new PropertyOperations.Builder()
  .Set("age", 42)
  .Set("grade", "GOLD")
  .SetOnce("sign_up_date", "2020-07-03")
  .Build();

hackle.UpdateUserProperties(operations);
```

#### Set

Sets a User Property. Overwrites the existing value with the configured value.

```csharp
PropertyOperations operations = new PropertyOperations.Builder()
  .Set("age", 42)
  .Set("grade", "GOLD")
  .Build();

hackle.UpdateUserProperties(operations);
```

#### SetOnce

Sets a User Property value only once. If a property already exists for the property key, `setOnce` is ignored. For example, you can use this to set a user's registration date or initial registration location.

```csharp
PropertyOperations operations = new PropertyOperations.Builder()
  .SetOnce("sign_up_date", "2020-07-03")
  .SetOnce("initial_location", "Seoul")
  .Build();

hackle.UpdateUserProperties(operations);
```

#### Unset

Removes a configured User Property.

```csharp
PropertyOperations operations = new PropertyOperations.Builder()
  .Unset("membership_type")
  .Build();

hackle.UpdateUserProperties(operations);
```

#### ClearAll

Removes all User Properties.

```csharp
PropertyOperations operations = PropertyOperations.ClearAll();

hackle.UpdateUserProperties(operations);
```

## Reset User Properties

You need to reset previously configured information. When reset, all previously configured identifiers and properties are cleared.

{% hint style="danger" %}
Resetting the user also clears all User Properties stored on the server. If you want to handle logout, use `hackle.setUserId(null)`.

Setting null to userId handles logout on the client side.
{% endhint %}

```csharp
Hackle hackle = Hackle.GetInstance();

hackle.ResetUser();
```

Calling `ResetUser()` clears all previously configured identifiers and properties.


---

# 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://docs.hackle.io/en/development-guide/unity/unity-user-info.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.
