# Set Targeting

## Overview

Hackle provides a feature called Targeting, which restricts A/B Test participation to only users with specific attributes, or users who have participated in specific A/B Tests or Feature Flags.\
For example, you can configure the A/B Test so that only Android users among mobile OS users participate.

Note that users who are subject to Override cannot be set as targeting targets.

{% hint style="info" %}
Users who participate in the A/B Test are subject to Traffic Allocation, and once allocated, they may be subject to Variation Distribution. For details, refer to the [Variation Distribution Process](/en/ab-test/group-distribution/ab-variation.md) document.
{% endhint %}

## Policy

1. **When you can configure**\
   You can configure or change settings from A/B Test creation through completion — that is, during **`Draft`**, **`Running, Paused`**, and **`Completed`** states.
2. **Default value**\
   If targeting is not configured, **`all users`** are eligible to participate in the A/B Test.
3. **Environment**\
   You can configure it in both the **`Production and Development Environments`**.
4. **Rules**\
   To restrict the target to specific users, at least 1 rule is required.\
   Targeting can have up to 10 rules. Each rule is combined using an OR operator, so satisfying just one rule makes a user a target.\
   For example, to target consumers who purchased a new product, you can define the rule "users who purchased a product in the 'New Product' category" and "users who purchased a product with 'new' in the product name," and configure it so that satisfying either rule qualifies the user as a target.
5. **Conditions**\
   A rule has 1 condition when created and can have up to 10 conditions.\
   Each condition is combined using an AND operator, so all conditions must be satisfied to be a target.\
   For example, to target users who are Android users among mobile OS users AND are in their 30s, they must satisfy both "user with Android mobile OS" and "user in their 30s."
6. **Properties**\
   Conditions can be configured using properties. Therefore, you need to integrate a Hackle SDK that supports properties and be able to collect at least the user properties defined in the targeting rules.\
   For more details on properties, refer to the \[Properties] document.\
   You can also configure conditions using A/B Tests or Feature Flags.

## Structure of rules and conditions

{% hint style="warning" %}
Rules and conditions can be composed of the following combinations:

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

(2) **`A/B Test (Feature Flag) + Operator + A/B Test Group (Feature Flag Status Value)`**

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

For example, if you are collecting the user's operating system under the property key `osName` and want to target Android users among mobile OS users, you can create the following combination:

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

The first combination created becomes the first rule. Depending on whether you add another combination to this rule using AND or OR, you can create a completely different type of target.

Let's look at operators and AND/OR in more detail below.

### Operators

Operators are used when setting conditions and describe the relationship between the property key and property value.\
Hackle provides a total of 22 operators. **You must choose the appropriate operator based on the type of property value that the selected property key holds.**

Refer to the table below for more details.

| Operator                   | Property Value Type | Selectable Number of Property Values                                |
| -------------------------- | ------------------- | ------------------------------------------------------------------- |
| is one of                  | String              | Multiple selection available                                        |
| is not one of              | String              | Multiple selection available                                        |
| starts with one of         | String              | Multiple selection available                                        |
| does not start with one of | String              | Multiple selection available                                        |
| ends with one of           | String              | Multiple selection available                                        |
| does not end with one of   | String              | Multiple selection available                                        |
| contains one of            | String              | Multiple selection available                                        |
| does not contain one of    | String              | Multiple selection available                                        |
| =                          | Number              | Multiple selection available                                        |
| ≠                          | Number              | Multiple selection available                                        |
| >=                         | 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 living in metropolitan cities, since they only need to live in one of the six metropolitan cities, you can define the rule as follows:

{% hint style="success" %}
Creating the \[Users living in a metropolitan city] rule

* Property: Residence (assuming the property key for this attribute is `residence`, and the property value type is String)
* Operator: is one of
* Property values for the operator: "Incheon", "Daejeon", "Daegu", "Ulsan", "Busan", "Gwangju"
  {% endhint %}

### AND and OR

AND and OR take two combinations as operands and have the following meanings:

1. **AND**\
   Both operands must be satisfied to be included in the target.\
   For example, for 'Android mobile OS user **AND** user with address in Seoul,' only users who use a mobile device with an Android OS **and** whose address is in Seoul are targeted.
2. **OR**\
   Only one of the operands needs to be satisfied to be included in the target.\
   For example, for 'Android mobile OS user **OR** user with address in Seoul,' users who use a mobile device with an Android OS **or** users whose address is in Seoul are targeted.

{% hint style="info" %}
How AND and OR are used in targeting

* The AND operator is used **when adding a condition to a rule**. The more AND operators you use, the more conditions must all be satisfied to be included in the target, so the target range narrows.
* The OR operator is used **when adding a rule**. Only one of the rules needs to be satisfied to be included in the target, so the more OR operators you use, the wider the target range becomes.
  {% endhint %}

## Configure targeting in the Dashboard

### When creating an A/B Test

You can set targeting conditions when creating an A/B Test.

{% hint style="warning" %}
You do not need to configure it at the creation stage!

You can configure it after creation, or modify what you set at this stage.
{% endhint %}

On the A/B Test creation screen below, you can find the **`A/B Test Targeting`** section at the very bottom.\
The default is **all users**.

![](/files/pwSKSdh0pBgWiIYogcay)

Clicking the **`+ Set Targeting`** button lets you configure the first condition of the first rule, as shown in the screenshot below.

![](/files/5Ow2o1bKQHaqUV1v8Ryb)

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

1. Property Key
2. Operator. Select considering the type held by the property key.
3. Property Value. Depending on the operator, it may not be selectable or multiple values may be available.
4. Delete the rule.
5. Add a condition.
6. Add a rule.

Clicking the **`+ Add AND Condition`** button (5) adds a condition to Rule 1 as shown in the screenshot below, and clicking the **`+ Add Rule`** button (6) adds Rule 2.

![](/files/GoMwxrH6yIXmBBiCY53q)

As mentioned earlier, a rule can have up to 10 conditions, and targeting can have up to 10 rules.\
Remember that adding a condition uses the AND operator, and adding a rule uses the OR operator.

After entering the information required for test creation and completing the targeting configuration, click the **`Create test`** button to complete the setup.

### After creating the A/B Test

You can view the A/B Test targeting configuration in the common header area at the top of the A/B Test detail page.\
To the right of the configuration information, you will see a button called **`Set Targeting`**. Click this button to configure targeting or edit the existing configuration.

![](/files/NLjNCZLBlsLG7m7DK0qR)

For an initial configuration, you need to set the first condition of the first rule, the same as when creating an A/B Test.\
The values to enter or select and the description of each button are the same as on the A/B Test creation screen.

## Viewing the configuration in the Dashboard

You can view the A/B Test targeting configuration in the common header area at the top of the A/B Test detail page.

### No targeting configured (no rules)

When targeting is not configured — meaning there are no rules — users participating in the A/B Test are not restricted, so **all users** are targeted.

**When the A/B Test status is Draft**

![](/files/3xM7CbTj4VXclVDIfE47)

① shows that all users are targeted.\
② the Set Targeting button allows you to configure targeting.\
③ shows example rules. These are not actual rules but show what rules would look like if configured.

**When the A/B Test status is not Draft**

![](/files/b1Z5UJBdpyAup7DsqwFM)

① shows that all users are targeted.

### Targeting configured (1 or more rules)

When targeting is configured, users participating in the A/B Test are restricted, meaning there are 1 or more rules.

**When the A/B Test status is Draft**

![](/files/j6oDbp7E3vKE1TnPM4rU)

① shows how many rules are configured.\
② indicates the rules are collapsed. By default, all rules are collapsed rather than expanded.\
③ the Set Targeting button allows you to configure targeting.\
④ shows a rule preview. It displays Condition 1 of Rule 1. To see additional information, click ② to expand.

Below is an example with the rules expanded.

![](/files/yo9dlAM2gfijkz2TUZ8x)

When expanded, ① and ③ are the same, but ②'s direction has changed, indicating the expanded state.\
Also, ④ shows all rules.


---

# 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/ab-test/create-and-configure/ab-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.
