---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://yandex.com/support/adfox/en/targeting/puid.md
  - https://yandex.com/support/adfox/ru/targeting/puid.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/support/adfox/en/llms.txt

# Custom targeting

Custom targeting is a module for setting up special types of targetings.

Besides the standard options (time, frequency, geography, and others), the account administrator can create up to 63 custom characteristics with any values and use them to target campaigns.

For standard targetings, Adfox fills in the values automatically. For custom targeting, you need to pass the characteristic values in the ad tag on the site page.

Let's look at what values we can pass and how to set up custom targeting in Adfox. To set up value transmission to the ad tag, contact your site's developers.

## Add characteristics {#add-puid}

You can set up custom characteristics on the **Settings** → **Custom targeting** tab.

#### Step 1. Add a targeting characteristic {#step-1}

1. In the characteristic's row, click <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.65868 11.809C2.55382 11.9139 2.34974 11.9989 2.19518 11.9989H0.27364C0.122513 11.9989 0 11.8798 0 11.7253V9.80372C0 9.6526 0.0862587 9.44383 0.189863 9.34022L7.49091 2.03917C7.59577 1.93432 7.76864 1.93718 7.8745 2.04303L9.95587 4.12441C10.0629 4.2314 10.0633 4.40439 9.95973 4.50799L2.65868 11.809ZM11.7955 2.67225L11.1634 3.30432C11.0606 3.40712 10.8858 3.40846 10.7788 3.30147L8.69744 1.22009C8.59158 1.11424 8.58917 0.940916 8.69458 0.835503L9.32665 0.203431C9.61198 -0.0648218 9.8859 -0.0707822 10.1496 0.203431L11.7955 1.84931C12.073 2.12382 12.0636 2.40768 11.7955 2.67225Z" fill="black"/></svg> **Settings**. This will open a window with settings.

1. Enable the use of the characteristic.

1. Set the parameters:

    - **Name**: The name of the characteristic on the **Custom targeting** tab. The maximum length is 256 characters.

    - **Targeting name**: The name of targeting for this characteristic in the ad campaign settings.

    - **Report name**: The name of the report for this characteristic in the list of reports.
        
1. Click **Change**.

#### Step 2. Add values for the new characteristic {#step-2}
 
Once you've added the characteristic, the ![](../_images/button-value.png =20x)**Values** and ![](../_images/button-value-group.png =20x)**Groups of values** buttons will appear in the characteristic's row on the **Custom targeting** tab. To add values:

1. In the characteristic's row, click ![](../_images/button-value.png =20x) → **Add**. This will open a window with settings.

1. Set the parameters:

    - **ID (passed to the ad tag)**: The parameter passed to the ad tag. The ID must consist only of Latin letters, numbers, and the following characters: `%+.=/()-`. The maximum length is 65 characters.

    - **Value (shown in the interfaces)**: The name of the value in the ad campaign targeting settings and in the reports. The maximum length is 256 characters.

    - **Disable the value where there are disabled values (targeting is set)**: This option stops showing the previously configured ads to users who match this value. This only applies to the ad campaigns created before the value was added. In new ad campaigns, this default value will be included in targeting.

1. Click **Add**.

{% note alert %}
        
You can set up to 10,000 values for a single characteristic.
        
{% endnote %}
        
You can combine values into groups. Then, when setting up targeting for an ad campaign, you'll be able to select all the required values with one click. For example, you've added the “age” characteristic and specified values from 15 to 35 for it. You usually set up targeting by age range: 15–20, 21–25, 26–30, and 31–35. Create four matching groups and add the required values to each. Then, when setting up an ad campaign, you won't need to list all the values in the targeted range. You'll just select a group, and all the required values will be included automatically.

To add a group of values: 

1. In the characteristic's row, click ![](../_images/button-value-group.png =20x) → **Add**.

1. In the window that opens, click **Add** and specify the group name.

1. Go to the **Values** tab and select the values for this group.

1. Click **Change**. The group will appear in the targeting settings for the ad campaign.

## Set up custom targeting {#target-puid}

You can set targeting on the **Targeting** → **Custom targeting** tab.

Select a characteristic from the list, check all the required values, and click **Change**. After that, you can select the next characteristic from the list and apply the same settings. If groups of values are added to a characteristic, you can manage the list of values by enabling and disabling groups only.

The **<unknown, not set>** option controls whether banners are shown when Adfox gets no value or a value that isn't in the list of characteristic values.

## Change the embed code {#embed-code}

If additional targeting characteristics were enabled after the ad tags were installed on the site, you need to add new parameters to the ad tag or retrieve the ad tag in the interface.


### Add parameters to the embed code

Add the `puidN: value` parameter to the `params` object, where:

- `N` is the number of the characteristic from 1 to 63.
- `value` is the value for targeting from the **ID** field.

For example, the following value can be added for the “Metro station” characteristic in the directory:

#|
|| **ID (passed to the ad tag)** | **Value (shown in the interfaces)** ||
|| `004ca1aa93adb0164440a7501a47c86` | Skhodnenskaya (Tagansko-Krasnopresnenskaya) ||
|#

You need to transmit the value from the **ID** field to the ad tag:

```javascript
params: {
    puid1: '004ca1aa93adb0164440a7501a47c86'
}
```

If this ID is then received in a request, it will be displayed in Adfox reports as “Skhodnenskaya (Tagansko-Krasnopresnenskaya)”.


{% note info %}

The passed `puid` variable must not exceed the browser's limit for total HTTP request string length.

{% endnote %}

You can pass multiple values to a single parameter separating them by `:` (colons). If the ad campaign is targeted at at least one of the received values, it will be shown.

Example 1. Adding puid1 with a single value and puid2 with multiple colon-separated values:

```javascript
params: {
    pp: 'g',
    ps: 'bnfx',
    p2: 'evbi',
    puid1: 'woman',
    puid2: '16:17:18:19'
}
```

{% cut "Adding parameters to the mobile app code" %}


Use an `AdRequest` object to pass the `adf_puidN` parameter, where `N` is the number of the characteristic from 1 to 63 and the value for targeting.

Example (Android):

```java
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("adf_puid1", "value");
```

Example (iOS):

```java
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
parameters[@"adf_puid1"] = @"value";
```


{% endcut %}

{% cut "Add parameters for XML code" %}


Add a parameter with a value as `name=value&` or `name=value&amp;` (depending on your chosen parameter separator), where `name` is the parameter name (puidN), and `value` is the value without quotes.

Example of adding puid1 with a single value and puid2 with multiple colon-separated values:

```javascript
yandex.ru/ads/adfox/166283/getCode?pp=g&ps=bnfx&p2=evbi&pr=<random>&dl=<page_url>&puid1=woman&puid2=16:17:18:19
```

The above code will show campaigns targeted at 16-year-old female visitors.


{% endcut %}


## Reports {#reports}

If a single value was passed from the site page to the parameter, it will also be recorded in the log, and the report will be generated based on this recorded value.

If several values were passed from the site page to the parameter at the same time, the report is generated as follows:

- The value that has the largest valueID (system identifier of the characteristic value) will be logged.

- If the campaign wasn't targeted to this value but could run for another value from the request, the report will show the logged value with the highest valueID. But this doesn't mean that the campaign was shown incorrectly according to the targeting settings.

Example: The request passes values to `puid1=g38:m38:m42:m21`.

For the first characteristic, we have the following value directory:

**valueID** | **ID (passed to the ad tag)** | **Value (shown in the interface)** 
----- | ----- | -----
25190 | g38 | Cartoons for children
25192 | m38 | Russian cartoons
25195 | m42 | Cartoons animated series


**valueID = 0**: Have unknown values passed to the request code.

For example, you run a campaign that's targeted to an unknown value when the first three values are disabled.

When a request like this comes in, the campaign is shown because the request includes an unknown value. One of the received values, namely m42, will be logged, because it has the highest valueID. The impression will be counted as “Cartoons animated series” value in the report for this ad campaign. This isn't treated as an error, since the request includes a value that's allowed for showing ads.


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


