• SDKS
No results for ""


Setting user attributes

Read time: 1 minute
Last edited: Mar 30, 2021


This topic explains what user attributes are, how they impact what you see in LaunchDarkly, how to configure them, and how LaunchDarkly uses them to calculate and display flag settings for users.

Understanding users

Users are people, services, machines, or other resources that encounter feature flags in your app. Any identifier that uniquely corresponds to a target can be designated as a user.

A more precise way to refer to one user is as a user object.

Viewing and managing users

By default, all of the attributes in your user objects are sent to LaunchDarkly. This data lets LaunchDarkly calculate the current flag settings for users and powers the autocomplete functionality throughout the LaunchDarkly UI.

Access user pages from the Users dashboard. To learn more, read The Users dashboard.

A user's page.
A user's page.

The SDK does not use the attributes on the Users dashboard to evaluate flags
The SDK only evaluates flags based on the user object you provide. The SDK does not use the attributes shown on the dashboard, and user attributes are not synchronized across SDK instances. You must provide all applicable user attributes for your targeting rules to apply correctly.

Creating private user attributes

You may not want to send all attributes back to LaunchDarkly. The security or data protection requirements of your organization may require you to limit what customer or user data is transmitted from your service to a third-party platform like LaunchDarkly.

For example, you may want to target customers by their personally identifying information (PII), such as their email address, without sending the email address to LaunchDarkly.

LaunchDarkly's private user attributes feature lets you choose which attributes get sent back to LaunchDarkly without sacrificing the ability to target user segments. This lets you create targeting rules and segments based on the attributes without having to send sensitive data back to LaunchDarkly.

Configuring private attribute settings in your SDK

There are three different ways to configure private attributes:

  • You can mark all attributes private globally in the LDClient configuration object.
  • You can mark specific attributes private by name globally in the LdClient configuration object.
  • You can mark specific attributes private by name for individual users when you construct LDUser objects.

User keys cannot be marked private.

To learn more about setting these configuration options, read your SDK's documentation.

Implications of using private attributes
If a feature flag contains targeting rules that reference private attributes, the user page may not be able to calculate flag settings for your users. The Users page indicates when it is unable to calculate flag settings because of private attributes. LaunchDarkly cannot perform autocomplete attributes you have made private.

Setting custom user attributes

A user object is constructed of the user's key, standard attributes, and custom attributes.

Custom attributes contain any other user data that you would like to use to conditionally target your users. Custom attributes are provided in the users object. Here is an example user object which contains custom user attributes:

3"firstName": "Bob"
5 "groups":[
8 ]
9 }

The user's key is not optional, but the following standard attributes are all optional:

emailMust be a string.
firstNameMust be a string.
lastNameMust be a string.
nameMust be a string.
avatarMust be an absolute URL to an avatar image for the user.
ipMust be an IP address.
countryMust be a string.
anonymousMust be a boolean. This attribute prevents the user's other attributes from being transmitted to the events endpoint, and prevents the user from showing up on the dashboard.