---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.com/support/adfox/en/targeting/logic.md
  - https://yandex.com/support/adfox/ru/targeting/logic.md
  - href: en/targeting/logic.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/support/adfox/en/llms.txt

# By logic statements

With targeting by logical expression, you can specify values for ad campaign impressions using the `AND`, `OR`, and `NOT` (`≠`) logical expressions.

Logical targeting supports [custom targeting](https://yandex.com/support/adfox/en/targeting/puid.md).

An assistant can be granted the account administrator [access](https://yandex.com/support/adfox/en/settings/users/assistant.md#available-targeting) level to logical targeting. All the characteristics will be available to the assistant. It is impossible to limit the visibility of specific characteristics.

## How it works {#about}

All targeting types in Adfox use the `AND` condition. This means that if you set up targeting by frequency and geography for your campaign, the ad will only show when both conditions are met.

With logical targeting, you can use logical expressions to create complex rules for showing ads. These expressions are written as blocks, which can be a set of possible values or a logical operation that links child blocks.

#### Examples {#examples}

`[ ]`: A block with a logical operation.

`( )`: A block of values.

- {% cut "Example with the `NOT` (`≠`) condition" %}

    ```
    [(puid1=A) AND (puid2≠B)]
    ```

    The campaign can be served only if the request includes `puid1=A` and `puid2=C` values. If the request includes `puid1=A` and `puid2=B` values, the campaign won't be served.
        
 {% endcut %}

- {% cut "Example with the `AND` condition" %}

    ```
    [(puid1=A) AND (puid2=B)]
    ```
    The campaign can be served only if the request includes the combination of `puid1=A` values.
        
 {% endcut %}

- {% cut "Example with the `OR` condition" %}

    ```
    [(puid1=A) OR (puid2≠B)]
    ```

    The campaign can be served if the request includes one of the values `puid1=A` or `puid2=C`. If the request includes `puid1=C` and/or `puid2=B` values, the campaign won't be served.
        
 {% endcut %}

- {% cut "Example with multiple conditions" %}

    ```
    [[(puid1=A) AND (puid2=B)] OR [(puid1=С) AND (puid2=D)]]
    ```

    The campaign can be served only if the request includes a combination of values.
        
 {% endcut %}

{% note info %}

If you're using logical and [custom targeting](https://yandex.com/support/adfox/en/targeting/puid.md), the campaign will be displayed if all of the targeting set is performed at the same time.

{% endnote %}

## Set up targeting {#settings}

1. Go to **Targeting** → **Add a targeting condition** → **By logic statements**.

1. Set up logical expressions:
    
    1. In the drop-down list for the condition inside Logical Block 1, choose the characteristic you want to target and enter the value after the `=` sign. 
    
        {% note info %}
        
        You can add one or more values to a single condition.
        
        {% endnote %}

        To exclude values using the `NOT` logical expression, click the `=` sign to change it to `≠`.

    1. Use the **Add a logical block** button to add as many logical blocks as you need. Blocks are linked with the `OR` logical expression.

    1. Use the **Add a condition** button to add as many conditions as you need to each block. Conditions within a block are linked with the `AND` logical expression.

1. <!-- source: en/_includes/targeting/add-condition.md -->
   After making changes, click **Apply** and save the targeting criteria.
   <!-- endsource: en/_includes/targeting/add-condition.md -->

<!-- source: en/_includes/feedback.md -->
## Contact support


<a href="en/form"> <!--ссылка, куда ведет кнопка. Если внутренняя ссылка, пишем без .md и .html --> 
  <span class="button">Send an email</span> <!--текст на кнопке--> 
</a>



<!-- source: en/_includes/styles/button.md -->

<!-- endsource: en/_includes/styles/button.md -->
<!-- endsource: en/_includes/feedback.md -->
