---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://ads.yandex.com/helpcenter/en/dev/android/target-adfox.md
  - https://ads.yandex.com/helpcenter/ru/dev/android/target-adfox.md
  - https://ads.yandex.com/helpcenter/zh/dev/android/target-adfox.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ads.yandex.com/helpcenter/en/llms.txt

# Ad targeting in Adfox 

<!-- source: en/dev/_includes/target-adfox.md -->
In Adfox, targeting can be set up at [different levels](*level). Adding context data to the request can significantly enhance the quality of advertising and increase your revenue.

To use [additional targetings](https://yandex.com/support2/adfox/en/targeting/puid), [logical targeting](https://yandex.com/support2/adfox/en/targeting/logic), or [keyword targeting](https://yandex.com/support2/adfox/en/targeting/words) for direct sales, implement passing the relevant parameter values in the ad request to Adfox.
<!-- endsource: en/dev/_includes/target-adfox.md -->

<!-- source: en/dev/_includes/target-adfox.md -->
## Set up targeting {#setup-adfox}

Determine which type of targeting is appropriate for your needs and implement passing the relevant parameter values:

#|
|| **Type of targeting** | **Parameter name** | **Description** ||
||  Keyword targeting | `adf_pk` | Serve ad banners for select keywords. For example, you can insert search queries in the ad tag or set up targeting by names and interests, using your user base to more accurately identify the target audience.

To do this, insert parameters with values in `adf_pk = value` format into the ad tag's `params` object, where:

- `adf_pk` is the parameter name.
- `value` is the parameter value enclosed in single quotes. The value can contain:
     - Keywords: Up to 10 space-separated keywords.
     - Phrases: Only one phrase.

Not case sensitive. No value encoding is required.

For more information, see [Adfox Help](https://yandex.com/support2/adfox/en/targeting/words) ||
|| Additional and logical targeting | `adf_puidN` | Serve ad banners based on additional targetings.

You can specify custom targeting values. For example, you can target only users with the test build or trigger banner impressions based on a specific internal metric.

To do this, pass the parameter with the values `adf_puidN = value` in the ad request to Adfox.

<!-- source: en/dev/_includes/add-target-steps.md -->
{% cut "Steps for setting up additional targeting" %}

1. Create a dictionary for a targeting characteristic. The dictionary should contain a list of values:

    - The key is passed to the ad tag in the app.

    - The value is included in the targeting settings and can be toggled.

    In Adfox, you can add up to 63 custom dictionaries for your characteristics. Each dictionary can hold up to 10,000 values and can be updated with new key-value pairs as needed.

1. Upload the dictionary for any free additional targeting characteristic through the Adfox interface.

1. Implement passing the keys to the index of the characteristic for which you created the dictionary.

{% endcut %}
<!-- endsource: en/dev/_includes/add-target-steps.md -->

To use logical targeting, pass the values for the additional targetings from the app. In the Adfox interface, you can also set up ad campaign impressions using the `AND/OR/NOT` conditions.

For more information, see [Adfox Help](https://yandex.com/support2/adfox/en/targeting/puid) ||
|| IDs for debugging banners | `adf_p1`: Placement ID.

`adf_pfc`: Campaign ID.

`adf_pfb`: Banner ID. | Call a banner from a specific placement or campaign.

{% note warning %}

We recommend calling specific banners only for testing purposes. Otherwise, no other banners will appear on the placement.

{% endnote %}

To call a specific banner, pass two values: `adf_p1` and `adf_pfb`. Banner, campaign, and placement IDs can be found in the Adfox interface. ||
|#
<!-- endsource: en/dev/_includes/target-adfox.md -->

<!-- source: en/dev/_includes/target-adfox.md -->
## Sample code (Kotlin) {#examples-android}

[//]: # (пример для Android)

```kotlin
val targeting = AdTargeting.Builder()
            .setAge("25")
            .setGender(Gender.MALE)
            .setLocation(Location("provider"))
            .setContextQuery("Купить легковой автомобиль с пробегом в Москве")
            .setContextTags(listOf("Купить легковой автомобиль", "автомобиль с пробегом", "в Москве"))
            .build()
val adRequest = AdRequest.Builder("your-ad-unit-id")
            .setTargeting(targeting)
            .build()
```
<!-- endsource: en/dev/_includes/target-adfox.md -->

[*level]: Levels in descending order of priority:
- Banner.
- Placement on the platform.
- Placement in the section.
- Placement on the site.
- Campaign.