Documentation Index
Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This topic explains what anonymous contexts are, how their information is handled in LaunchDarkly, and how they contribute to your monthly account usage. You can designate any context as an anonymous context. Anonymous contexts work just like other contexts, except that they don’t appear on your Contexts list in LaunchDarkly. You can’t search for anonymous contexts on your Contexts list, and you can’t search or autocomplete by anonymous context keys. Anonymous contexts still count toward your limit for monthly contexts or monthly active users (MAU). Here is an example of an anonymous context:Configure your SDK: Anonymous contexts and users
You can use anonymous contexts to hide personally identifiable information (PII), but we recommend using private attributes instead. To learn more, read Using private context attributes.
Manage stored contexts
There is no limit to the number of contexts you can evaluate or target with LaunchDarkly. However, LaunchDarkly stores only a limited number of unique context keys per environment and per 30-day period. Stored contexts are what appear in the Contexts list and what count toward billing usage metrics such as MAU. This means you may see higher usage counts than expected if you unintentionally create many unique context keys. For example:- Creating contexts that include request IDs. Each request generates a new unique context key, which LaunchDarkly then stores, even if the context represents the same end user.
- Creating contexts from server-to-server communication where there are no human operators, only software components interacting.
- Using LaunchDarkly to configure log levels or tracing with an identifier such as a timestamp. Each timestamp is treated as a unique context key.
Manage anonymous contexts
LaunchDarkly identifies all contexts by their unique key, including anonymous contexts. Using unique keys for anonymous contexts allows you to observe anonymous traffic interacting with your application, target anonymous traffic with percentage rollouts, and use Experimentation. Anonymous contexts can raise your MAU count, but there are actions you can take to manage your MAU when using anonymous contexts. To learn more about MAU, read Account usage metrics.Store anonymous keys locally
If you provide the anonymous context key yourself, you must ensure that the context uses that same key on each subsequent visit to avoid inflating how many contexts you evaluate. One strategy to make sure that you’re using the same anonymous context key each time is to store the unique identifier yourself in a cookie or local storage. Because this is such a common strategy, we’ve implemented it directly into many of our client-side SDKs. If you use a client-side SDK and want to use a unique key for your anonymous contexts, you can defer key generation onto the SDK. To do this, build a context object and omit the key completely. The SDK generates a unique identifier for the context and persists this unique identifier in local storage. (LaunchDarkly SDKs do not store information in cookies.) Each subsequent context evaluation without a context key uses that saved unique identifier. Check your SDK’s documentation to confirm whether it will generate a unique key for your anonymous contexts.Configure your SDK: Anonymous contexts and users
Wait to initialize your SDK
If you don’t need to expose flags to anonymous contexts, don’t initialize the SDK client for anonymous contexts. Instead, wait to initialize the client until after you know who your audience is. To learn more about SDK client initialization, read the Getting started documentation for your SDK.Use a shared key between anonymous contexts
Click to expand details on using a shared key
Click to expand details on using a shared key
Associate anonymous contexts with logged-in end users
Before they log in, an end user might be represented by a device context. After they log in, they might be represented by two contexts, with one context kind based on their device and the second context kind based on their user information. This one person is now represented by two unique context keys. If you want to associate two contexts with each other, you should identify a multi-context that includes both individual contexts when you want the association to occur. Unlike the aliasing method, the association doesn’t persist between calls. You must send the contexts you want to associate in eachvariation or identify call and each track call.
Try it in your SDK: Identifying and changing contexts
Anonymous users and aliasing
If you are not yet using an SDK version that supports contexts, you can associate an anonymous user with a specific, logged-in user using thealias method.
To learn more, read How to use contexts instead of alias.
Click to expand details on the deprecated alias method
Click to expand details on the deprecated alias method
This section explains aliasing users, which is a deprecated feature for LaunchDarkly SDKs that have been updated to use contexts. For a list of SDKs that still support this feature, read Aliasing users.
alias events. Alias events connect two user keys and register them as one event-sending entity.If you use Data Export or Experimentation, alias events are useful because they make the data represented in destinations and experiment results easier to understand. Alias events enable Data Export destinations to correlate the two user keys referring to the same underlying user. They also enable experiments to recognize when impressions and conversions occurred for a user, even if the user key changed between the two events.To learn more about configuring your SDK to send alias events, read Aliasing users.