> For the complete documentation index, see [llms.txt](https://docs.luciq.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.luciq.ai/references/user-identification-data/user-attributes.md).

# User Attributes

API reference for Luciq user attributes. Add, retrieve, and remove custom attributes that travel with every report from that user.

Attributes are collected by default by the Luciq SDK. These attributes contain information related to the users. You can add custom attributes using these APIs. Attributes can be added, retrieved, and removed.

### Adding

Attach custom attributes to your user by passing two strings to the set attribute API. Much like a dictionary or map, the two strings are the value and key of the attribute.

**Adding Attributes**

{% tabs fullWidth="true" %}
{% tab title="iOS - Swift" %}

```swift
Luciq.setUserAttribute("True", withKey: "Logged in")
Luciq.setUserAttribute("False", withKey: "Completed IAP")
```

{% endtab %}

{% tab title="iOS - ObjC" %}

```objectivec
[Luciq setUserAttribute:@"True" withKey:@"Logged in"];
[Luciq setUserAttribute:@"18" withKey:@"Age"];
```

{% endtab %}

{% tab title="And - Java" %}

```java
Luciq.setUserAttribute("Age", "18");
Luciq.setUserAttribute("LoggedIn", "True");
```

{% endtab %}

{% tab title="And - Kotlin" %}

```kotlin
Luciq.setUserAttribute("Age", "18")
Luciq.setUserAttribute("LoggedIn", "True")
```

{% endtab %}

{% tab title="RN" %}

```javascript
Luciq.setUserAttribute("Age", "18");
Luciq.setUserAttribute("Logged", "True");
```

{% endtab %}

{% tab title="Flutter" %}

```dart
Luciq.setUserAttributeWithKey(String value, String key)

//Examples
Luciq.setUserAttributeWithKey("18", "Age");
Luciq.setUserAttributeWithKey("True", "Logged In");
```

{% endtab %}
{% endtabs %}

### Retrieving

You can retrieve all attributes related to a user using the retrieve API. This API returns an `NSDictionary` for iOS and a `HashMap` for Android.

**Retrieving Attributes**

{% tabs fullWidth="true" %}
{% tab title="iOS - Swift" %}

```swift
//Retrieving
let loggedIn = Luciq.userAttribute(forKey: "Logged in")
//Retrieve all
let allUserAttributes = Luciq.userAttributes()
```

{% endtab %}

{% tab title="iOS - ObjC" %}

```objectivec
//Retrieve one
NSString *loggedIn = [Luciq userAttributeForKey:@"Logged in"];
//Retrieve all
NSDictionary *allUserAttributes = [Luciq userAttributes];
```

{% endtab %}

{% tab title="And - Java" %}

```java
//Get map of all user attributes
HashMap<String, String> userAttrs = Luciq.getAllUserAttributes();
```

{% endtab %}

{% tab title="And - Kotlin" %}

```kotlin
//Get map of all user attributes
val userAttrs = Luciq.getAllUserAttributes()
```

{% endtab %}

{% tab title="RN" %}

```javascript
// Getting attribute
Luciq.getUserAttribute("Logged in", function(attribute) {
  // `attribute` is the return value
});

// Loading all attributes
Luciq.getAllUserAttributes(function (allAttributes) {
  // `allAttributes` Object containing all keys and attributes
});
```

{% endtab %}

{% tab title="Flutter" %}

```dart
// Getting attribute
Luciq.getUserAttributeForKey("Logged in");

// Loading all attributes
Luciq.getUserAttributes();
```

{% endtab %}
{% endtabs %}

### Removing

Attributes can be removed from a user by passing the key of the attribute you'd like to remove to the removal API.

**Removing Attributes**

{% tabs fullWidth="true" %}
{% tab title="iOS - Swift" %}

```swift
Luciq.removeUserAttribute(forKey: "Logged in")
```

{% endtab %}

{% tab title="iOS - ObjC" %}

```objectivec
[Luciq removeUserAttributeForKey:@"Logged in"];
```

{% endtab %}

{% tab title="And - Java" %}

```java
//remove a user attribute
Luciq.removeUserAttribute("KEY");

//remove all user attributes 
Luciq.clearAllUserAttributes();
```

{% endtab %}

{% tab title="And - Kotlin" %}

```kotlin
//remove a user attribute
Luciq.removeUserAttribute("KEY")

//remove all user attributes 
Luciq.clearAllUserAttributes()
```

{% endtab %}

{% tab title="RN" %}

```javascript
Luciq.removeUserAttribute("Completed IAP");
```

{% endtab %}

{% tab title="Flutter" %}

```dart
Luciq.removeUserAttributeForKey("Logged In");
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.luciq.ai/references/user-identification-data/user-attributes.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
