# User Targeting

## Overview

User Targeting is a feature that applies Feature Flag state values only to users with specific properties, or users who have participated in a specific A/B Test or Feature Flag. For example, it is possible to apply a Feature Flag to all users who use Android as their mobile operating system.

However, users subject to Individual Targeting cannot be subject to User Targeting.

{% hint style="warning" %}
Cohort targeting is not supported in server environment SDKs and is only supported in client SDK environments.
{% endhint %}

## Policy

1. **When you can configure it**\
   You can configure or change the settings at any time. When the Feature Flag is in the off state, all users are distributed to \[False].\
   However, note that if you configure it while the Feature Flag is in the on state, it will be applied to those users immediately upon saving.
2. **Default value**\
   \&#xNAN;**`All users`** is the default value. This means all users except those subject to Individual Targeting are subject to traffic allocation.
3. **Environment**\
   Can be configured in both the **`Production Environment`** and **`Development Environment`**.
4. **Rules**\
   If you want to restrict the target to specific users, a minimum of 1 rule is required.\
   Targeting can have a maximum of 10 rules. Each rule is independent. Therefore, satisfying just one of the rules makes a user the target.\
   For example, if you want to target consumers who purchased a new product, you can define a rule "users who purchased a product belonging to the 'New Product' category" and another rule "users who purchased a product containing 'New' in the product name," and configure it so that satisfying either one of these makes the user the target.
5. **Conditions**\
   A rule has 1 condition upon creation and can have up to 10 conditions.\
   Each condition is an operand of the logical operator AND. Therefore, a user becomes the target when all conditions are satisfied.\
   For example, if you want to target Android users who are in their 30s, the user must satisfy both the condition "user whose mobile operating system is Android" and the condition "user whose age group is 30s."
6. **Properties**\
   Conditions can be configured using properties. Therefore, you must integrate a Hackle SDK that supports properties and be able to collect at minimum the user properties defined in the targeting rules.\
   For detailed information about properties, refer to the \[Property]\(../../event-management/properties/README.md) document.\
   Additionally, conditions using A/B Tests and Feature Flags are also possible.

## Composition of Rules and Conditions

{% hint style="info" %}
Important!

Rules and conditions can be composed in the following combinations:

(1) **`Property Key + Operator + Property Value`**

(2) **`A/B Test (Feature Flag) + Operator + A/B Test Group (Feature Flag state value)`**

(3) **`Targeting Group + Operator + User Group Key`**
{% endhint %}

For example, if user OS information is being collected using a property named osName, and you want to target Android users among mobile OS users, you can create the following combination:

* Property Key: osName
* Operator: is one of
* Property Value: Android, android

The first created combination becomes the first rule.

### Property Key and Property Value

For detailed information about properties, refer to the \[Property]\(../../event-management/properties/README.md) document.

### Operator

Operators are used when setting conditions, and they describe the relationship between the property key and property value.\
Hackle provides a total of 22 operators, and **you must select the appropriate operator based on the type of property value the selected property key has**.

For more details, refer to the table below:

| Operator                   | Property Value Type | Number of Selectable Property Values                                |
| -------------------------- | ------------------- | ------------------------------------------------------------------- |
| is one of                  | String              | Multiple selection allowed                                          |
| is not one of              | String              | Multiple selection allowed                                          |
| starts with one of         | String              | Multiple selection allowed                                          |
| does not start with one of | String              | Multiple selection allowed                                          |
| ends with one of           | String              | Multiple selection allowed                                          |
| does not end with one of   | String              | Multiple selection allowed                                          |
| contains one of            | String              | Multiple selection allowed                                          |
| does not contain one of    | String              | Multiple selection allowed                                          |
| =                          | Number              | Multiple selection allowed                                          |
| ≠                          | Number              | Multiple selection allowed                                          |
| >=                         | Number              | Single item selection                                               |
| <=                         | Number              | Single item selection                                               |
| >                          | Number              | Single item selection                                               |
| <                          | Number              | Single item selection                                               |
| is true                    | Boolean             | Not selectable (property value 'true' is included in the operator)  |
| is false                   | Boolean             | Not selectable (property value 'false' is included in the operator) |
| version =                  | Version             | Single item selection                                               |
| version ≠                  | Version             | Single item selection                                               |
| version >                  | Version             | Single item selection                                               |
| version ≥                  | Version             | Single item selection                                               |
| version <                  | Version             | Single item selection                                               |
| version ≤                  | Version             | Single item selection                                               |

### Example

If you want to target users residing in metropolitan cities, since users only need to live in one of the six major metropolitan cities, you can define the rule as follows:

{% hint style="success" %}
Creating a rule for \[Users residing in metropolitan cities]

* Property: Residence (assume the property key for this property is residence, and property value type is String)
* Operator: is one of
* Property values to go in 'one of': "Incheon", "Daejeon", "Daegu", "Ulsan", "Busan", "Gwangju"
  {% endhint %}

### No Target Set (All Users)

When no target is set, i.e., when there are no rules, **all users except those subject to Individual Targeting** are subject to traffic allocation.

![](/files/aosm61AVfsbyxQ8Lld2n)

You can allocate traffic to all users by moving the slider or entering the percentage directly.

![](/files/N4Z840kg5tEyGx8WzM9F)

Use the **`Configure`** button in the upper right corner to save all changes and apply them to users.

## Configuring User Targeting

Click the **`Add User Targeting`** button to add a targeting rule.

![](/files/fylzsYUCH9xmAZuRPbdm)

The values to enter or select and the description for each button are as follows:

1. Property Key
2. Operator. Please select while considering the type of the property key.
3. Property Value. Depending on the operator, selection may not be available or multiple may be selectable.
4. Deletes the rule.
5. Adds a condition. Clicking this button adds 1 condition to the rule.
6. You can configure the rule's state. There are two options: False and True, and you can set the percentage directly.
7. Adds a rule. Clicking this button adds a new rule.
8. Sets the percentage for the remaining users not covered by any rule.

A newly added rule checks whether it is satisfied for users who do not satisfy the preceding rule.

![](/files/VVVr7XOffLywBDCZCo7P)

1. When there are 2 or more rules, you can change the order. Use the icon to the left of the rule name.
2. Adds a condition.
3. When a condition is added using button 3, a new line for entering the condition is added.
4. Among users who satisfy all conditions in the rule, the Feature Flag is applied to the percentage of users configured here. In this case, the Feature Flag is applied to 100% of the target users.

As mentioned earlier, a rule can have a maximum of 10 conditions, and targeting can have a maximum of 10 rules.\
After entering the information needed to create the test and completing the targeting configuration, click the **`Save`** button to finalize the settings.

### Target Set (1 or More Rules)

When a target is configured, there are 1 or more rules. The screenshot below shows a case with 2 rules configured.

![](/files/0wwrD1Bt43940DRJ3x11)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hackle.io/en/feature-flag/create-and-configure/ff-targeting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
