Setting user attributes
Read time: 1 minute
Last edited: Mar 30, 2021
Overview
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.
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 key
s cannot be marked private.
To learn more about setting these configuration options, read your SDK's documentation.
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:
1{2"key":"YOUR-USER-KEY",3"firstName": "Bob"4"custom":{5 "groups":[6 "YOUR-COMPANY",7 "YOUR-COMPANY-GROUP-2"8 ]9 }10}
The user's key is not optional, but the following standard attributes are all optional:
Attribute | Requirements |
---|---|
Must be a string. | |
firstName | Must be a string. |
lastName | Must be a string. |
name | Must be a string. |
avatar | Must be an absolute URL to an avatar image for the user. |
ip | Must be an IP address. |
country | Must be a string. |
anonymous | Must 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. |