The attributes are used to target users. They allow you to control which variations are shown to users based on user properties.

Example Walkthrough

To understand how attributes are used, let’s walk through a complete example. Let’s say you have launched a feature flag that has two variations: on and off. You want to show the on variation to all “registered” users of your application. To achieve this, you can define a new (boolean) attribute called “registered”. Then in feature flag targeting rules, you’d define a new rule to show the on variation when a user has “registered = true” property.

1. Create New Attribute

create a new attribute

2. Target Users by Attribute

target users by registered attribute

3. Pass Attributes in the SDK

You can now start passing attributes in your application through Unlaunch SDKs and they’ll be assigned appropriate variation based on the value of the attribute. For example, in JavaScript, you’d do something like this:

3a. JavaScript Example
// Set registered attribute to true to get the "on" variation.
let attributes = {
    "registered": true

const ulclient = ULClient.initialize(
    ['mfa-feature'], // feature name
    'anonymous',     // user id
    attributes,      // Pass the attributes

ulclient.on('ready', function () {
    let variation = ulclient.variation(flag);

    if (variation === 'on') {
        // Show feature
    } else {
        // Don't show featyre
3b. Java Example
public static void main(String[] args) {
    // Create UnlaunchClient
    UnlaunchClient client = UnlaunchClient.create(

    // Wait for the client to be ready
    try {
        client.awaitUntilReady(2, TimeUnit.SECONDS);
    } catch (InterruptedException | TimeoutException e) {
        LOG.error("[DEMO] client wasn't ready " + e.getMessage());

    // Get variation for random identity and attributes
    String variation = client.getVariation(
            // Pass the registered attribute as true which returns "true".
            // Set this to false to get the "off" variation
            UnlaunchAttribute.newBoolean("registered", true));

    // Print variation
    LOG.info("getVariation() returned {}", variation);

    // shutdown the client to flush any events or metrics

This will print:

12:03:39.796 INFO  io.unlaunch.sdk.HelloAttributes - getVariation() returned on

Attribute Types

Unlaunch supports the following attribute types. To read more on attributes and associated operators

  • Boolean
  • String
  • Number
  • Set
  • Date
  • DateTime


In this article, we explored attributes and looked at an example of how to use them in Unlaunch. Attributes are used to target users in target rules to control variations that are assigned to users.