Galaxy Brain: The Power of Targeting Via User Attributes (And More) featured image

Galaxy Brain is an ongoing blog post series covering talks from our annual user conference, Galaxy.

Why are targeting rules powerful? They abstract business logic away from your codebase, which means you don't have to redeploy code just to give a user access to a new integration or feature. Targeting helps improve customer experience as well as developers’ experience of rolling out new features. 

Sunny Guduru, software engineer on the integrations team at LaunchDarkly, explored this topic at a Galaxy event. We’ll share some takeaways from Sunny’s talk (which you can watch in full below), and you can check out all the Galaxy talks right now, if you like.  

But first, a primer:

How targeting works

Sunny kicked off by briefly covering targeting basics, which can be grouped into three types:

  1. Feature flags or feature toggles: You can target these on or off, and they determine whether we serve a false or off variation for customers, or evaluate the rules for on variation.
  2. Individual targeting: For boolean feature flags, this lets us determine specifically which users are going to get which variations. 
  3. User targeting rules: This is where business logic comes into play. You can use rules to determine who gets access to a feature or functionality, for example by targeting users only with email addresses that match your company’s first. 

The next level: Custom attributes

Beyond targeting basic user attributes (like email, user IP address, or user ID location), things get really interesting when you start to employ custom attributes in your user targeting rules. 

“So what are custom attributes exactly? They're attributes that can be string, boolean, number, or array," Sunny says. "These attributes can be used in targeting rules just like regular user attributes, and the attributes can be changed for every flag evaluation.”

LaunchDarkly’s integrations team didn’t want to create a new feature flag for every single integration they roll out, so they opted instead for a single, generic flag. They then use custom attributes to roll out integrations to specific users. 

To help us understand the power of custom attributes, Sunny gave the example of a sneaker store that offers exclusive drops for its most loyal customers. With custom attributes you can enable sales of specific shoes based on a user attribute, such as their customer loyalty score. All customers may be able to view the exclusive shoes, but only those with the correct status can actually purchase them. 

User targeting is just the beginning

Rules that target specific user attributes are just scratching the surface of possibility when it comes to experimentation and delivery. We recently announced custom contexts for LaunchDarkly. Instead of being limited to targeting one thing at a time (usually users), custom contexts allow teams to deliver to as many kinds of things they want, all at the same time. 

What can you target instead?

You can use custom contexts to target locations, namespaces, facilities, tenants, applications, devices, vehicles, services, companies, and organizations—or any combination of these—to experiment and deliver with even more fine-grained control. 

For instance, this could enable a medical records company to experiment with a new clinic form by rolling out to a random sample of its facilities first. Or, a fast food chain might target a specific app user, the type of device they’re using, and the specific location that user is visiting, to show them offers available at that restaurant. 

For more real-world examples of custom contexts and to see how to get started, check out the announcement post here.

Pitfalls and best practices for feature flags

Sunny wrapped his talk by sharing best practices from the integrations team, which is doing some cutting-edge work with feature flags and targeting (so they would know!) 

Keep a clean house

Name your flags and name them well. This makes it easier for all team members to know what they’re looking at, and simplifies the task of cleaning up unused flags. 

“We have a diagram internally that shows the association between a customer's plan and what integrations they have,” says Sunny. “That's really useful to have for feature flags that get really complicated.” 

Feature flags can indeed get complicated (that’s why they’re powerful!), so adequate documentation is important.

Remember the default variations

Don’t get caught out with an all-or-nothing feature flag rule. Sunny shared the example of a feature flag that either shows all shoes for sale, or only the exclusive shoes. 

“You really have to run through the different use cases to make sure you get it right,” he says.


For more on targeting in LaunchDarkly, check out our docs. To watch more talks from our Galaxy conference, go here.

Related Content

More about Galaxy

April 4, 2023