> For the complete documentation index, see [llms.txt](https://docs.hackle.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackle.io/en/ab-test/create-and-configure/ab-targeting.md).

# Set Targeting

Learn how to define who participates in an A/B Test and how to build the rules.

Targeting lets you include only specific users in an A/B Test. You can use user properties, A/B Tests, Feature Flags, and targeting groups as conditions.

{% hint style="info" %}
A/B Test participants are first subject to Traffic Allocation. Once traffic is allocated, they may be subject to Variation Distribution.

For the full process, see [Variation Distribution Process](/en/ab-test/group-distribution/ab-variation.md).
{% endhint %}

{% hint style="warning" %}
Users subject to Override cannot be included in targeting. Cohort targeting is not supported in server-side SDK environments; it is only supported in client SDK environments.
{% endhint %}

## Policy

<table data-view="cards"><thead><tr><th>Policy</th></tr></thead><tbody><tr><td><strong>When you can configure</strong><br>You can configure or change targeting from A/B Test creation through completion.<br><br>Applicable statuses: <code>Draft</code>, <code>Running</code>, <code>Paused</code>, <code>Completed</code></td></tr><tr><td><strong>Default value</strong><br>If targeting is not configured, <code>all users</code> are eligible to participate in the A/B Test.</td></tr><tr><td><strong>Environment</strong><br>You can configure it in the <code>Production</code> and <code>Development</code> environments.</td></tr><tr><td><strong>Rules</strong><br>To restrict the target to specific users, at least one rule is required. You can configure up to 10 rules.<br><br>Rules are combined with OR. Satisfying just one rule includes a user in the target.</td></tr><tr><td><strong>Conditions</strong><br>A rule has one condition when created. You can add up to 10 conditions per rule.<br><br>Conditions are combined with AND. All conditions must be satisfied to be included in the target.</td></tr><tr><td><strong>Properties</strong><br>To use a property condition, you need a Hackle SDK integration that collects that property.<br><br>A/B Tests and Feature Flags can also be used as conditions.</td></tr></tbody></table>

## 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 %}

Take the case where you collect the user's operating system under the `osName` property. To target Android users, build the following combination.

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

The first combination you create becomes the first rule. Adding a combination to the same rule connects it with AND. Adding it as a new rule connects it with OR.

#### Choosing an operator

An operator defines the relationship between the property key and the property value. Choose the operator that matches the property value type.

| 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                                               |

{% hint style="success" %}
Example: users living in a metropolitan city

If `residence` is a String type, select **is one of**.

Then add `Incheon`, `Daejeon`, `Daegu`, `Ulsan`, `Busan`, and `Gwangju` as property values.
{% endhint %}

### Configure in the Dashboard

{% stepper %}
{% step %}

#### Open targeting settings

At the top of the A/B Test detail page, select **`Set Targeting`**. The first condition of the first rule appears.
{% endstep %}

{% step %}

#### Enter the first condition

Select the property key, operator, and property value in order. Depending on the operator, you can enter one or multiple values.
{% endstep %}

{% step %}

#### Add a condition or a rule

Use **`+ Add AND Condition`** to add a condition to the same rule. Use **`+ Add Rule`** to add a new rule combined with OR.
{% endstep %}
{% endstepper %}

![](https://143363954-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyAVlNQhS253reum0Ce94%2Fuploads%2Fgit-blob-3344fd25f51da57ef700185da0aff9ea3eb18bdf%2F5cd2295-targeting-ab-create-03_5135a54eda5305b7.png?alt=media)

{% hint style="info" %}
Adding a condition narrows the target range. Adding a rule widens the target range.
{% endhint %}

### Check the configuration status

{% tabs %}
{% tab title="No targeting configured" %}
When there are no rules, **all users** are eligible to participate in the A/B Test.

In **Draft** status, you can see the target information, the **`Set Targeting`** button, and example rules.

![](https://143363954-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyAVlNQhS253reum0Ce94%2Fuploads%2Fgit-blob-2ceb365faad93fe27c382751bc562d4bd5fa07f5%2F6bfa760-targeting-sdp-01_8963b75c9ba13fb6.png?alt=media)

1. Indicates that all users are targeted.
2. Use `Set Targeting` to configure rules.
3. An example of how rules appear once configured. These are not actual rules.

In statuses other than Draft, only whether all users are targeted is shown.

![](https://143363954-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyAVlNQhS253reum0Ce94%2Fuploads%2Fgit-blob-f28397c9efec57fe8f5f1dbd2ab9ad66add54259%2Fd4b1ba0-_2023-04-12__11.09.01_2395451a90455bfa.png?alt=media)

Indicates that all users are targeted.
{% endtab %}

{% tab title="Targeting configured" %}
When there is at least one rule, the number of configured rules is shown. Rules are collapsed on the default view.

![](https://143363954-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyAVlNQhS253reum0Ce94%2Fuploads%2Fgit-blob-6fc0ceaf69458608f8fff39704f9dde26f90853f%2F42c9276-targeting-sdp-03_61c0772d46853086.png?alt=media)

1. Shows the number of configured rules.
2. Indicates the rules are collapsed.
3. Use `Set Targeting` to change the rules.
4. Previews the first condition of the first rule.

Select the expand icon to see all rules.

![](https://143363954-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyAVlNQhS253reum0Ce94%2Fuploads%2Fgit-blob-37aee42eca7a259a1d64baa61abf0a36adcca88d%2F669bdcb-targeting-sdp-04_47b8ef1639a5ac25.png?alt=media)
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.hackle.io/en/ab-test/create-and-configure/ab-targeting.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
