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

# By behavior

Targeting by behavior (or Retargeting campaigns) involves serving ads to a previously marked up audience. For example, you can display a banner only to those users who've already visited the site.

## How it works {#about}

1. You create temporary or permanent [categories](*category).

2. If you select temporary categories, action points are added for the targeting. Action points are code snippets or pixel links used to mark up the audience. You can embed them in the entire site or its individual elements, such as banners. [Learn more about action points](https://www.yandex.com/support/adfox/en/campaigns/tracingpoint.md).

    If you select permanent categories (used less frequently), they are assigned to sites, placements, or sections without action points being added.
    
3. You set up the campaign's targeting criteria for an audience, whether it's marked up for certain categories or not.

## Step 1. Create categories {#step-1}

1. Open **Settings** → **Categories** and go to the desired tab, depending on the category type:
    - To mark up the audience using action points, select **Temporary**.
    - To mark up the entire audience of the site, placement, or section select **Permanent**.

2. Click **+ Add**.

3. Name the category. If needed, set the category's activity period in days using the **Activity (days)** field.

4. Click **Add** to finish creating the category.

## Step 2. Add action points with temporary categories or assign permanent categories to sites {#step-2}

{% list tabs %}

- Action points

  1. Make sure that an advertiser has already been created in your account for a campaign with targeting by behavior, otherwise [create a new one](https://www.yandex.com/support/adfox/en/settings/users/advertiser.md#add_advertiser).

  2. Open the **Users** → **Participants** → **Advertisers** tab. Click the <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3.6 5.6C4.485 5.6 5.2 6.315 5.2 7.2C5.2 8.085 4.485 8.8 3.6 8.8C2.715 8.8 2 8.085 2 7.2C2 6.315 2.715 5.6 3.6 5.6ZM7.4 8C7.66522 8 7.91957 8.10536 8.10711 8.29289C8.29464 8.48043 8.4 8.73478 8.4 9C8.4 9.26522 8.29464 9.51957 8.10711 9.70711C7.91957 9.89464 7.66522 10 7.4 10C7.13478 10 6.88043 9.89464 6.69289 9.70711C6.50536 9.51957 6.4 9.26522 6.4 9C6.4 8.73478 6.50536 8.48043 6.69289 8.29289C6.88043 8.10536 7.13478 8 7.4 8ZM7.6 2C7.91517 2 8.22726 2.06208 8.51844 2.18269C8.80962 2.3033 9.0742 2.48008 9.29706 2.70294C9.51992 2.9258 9.6967 3.19038 9.81731 3.48156C9.93792 3.77274 10 4.08483 10 4.4C10 5.725 8.925 6.8 7.6 6.8C6.96348 6.8 6.35303 6.54714 5.90294 6.09706C5.45286 5.64697 5.2 5.03652 5.2 4.4C5.2 3.075 6.275 2 7.6 2Z" fill="black"/></svg>**Action tracking points** button next to the advertiser's name.

  3. Click **+ Add**.

  4. Configure the action points:
  
     - **ID**: This is the unique ID of the action point. The ID is assigned automatically. We don't recommend changing it.
  
     - **Name**: Required parameter. For example, it may correspond to the section name on pages where the action point will be set.
  
     - **Category**: Specify a temporary category you want to mark up users with.
  
     - **Template type**: Select **standard** or **POSIX.2**. If you want to register the address of the page where the action point is placed, choose how to save the template for checking the page address. Learn more about [template types](https://www.yandex.com/support/adfox/en/ad-inventory/codes/referer-templates.md).
  
     - **Referer template**: Sets the position of the action point on the site. Set a specific page template to embed the point only in those pages. Leave the field blank to register the action point on any page.
  
     - **Size**: Indicates the page value for the advertiser. For example, the weight of the home page may be 1, while the weight of the “thank you for your purchase” page may be 10.

  5. Click **Add**.

  6. Go to the **Action tracking points** tab and click <svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.50007 10.5002L6.00007 1.50024H7.50007L6.00007 10.5002H4.50007ZM0 5.24987V6.74973V6.74987L0.000115614 6.7498L3.75 9.00048V7.50048L1.24991 5.99992L3.75 4.49987V2.99987L0.000115614 5.2498L0 5.24973V5.24987ZM8.24985 9.00031V7.50031L10.7497 5.99987L8.24985 4.49994V2.99994L11.9995 5.24975L11.9998 5.24956V5.24994V6.74956V6.74994L11.9995 6.74975L8.24985 9.00031Z" fill="black"/></svg>**Ad tag** in the row with the desired action point. Copy the code snippet or link:
      - If you want to embed the action point for the entire site, copy **Yan loader code** and **Ad tag for the action point**.
      - To embed the action point in a banner, copy only the action point link.

- Assigning categories to sites

  1. Go to the **Inventory** section in the main menu, then select an existing site or add a new one.

  2. Click the <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** icon next to the site name.

  3. Select a permanent category from the dropdown list. To assign a category to a section or placement, select the desired category under its settings in the **Sections** tab.

    {% note tip %}

    If you set a category for the entire site, you don't need to select it for individual sections and placements: they will inherit it from the site.

    {% endnote %}
    
{% endlist %}

## Step 3. Create an ad campaign and banners {#step-3}

1. Create an [ad campaign](https://www.yandex.com/support/adfox/en/campaigns/add-new.md) and specify the placement of the campaign on the site where the behavior-targeted banner should be shown. We recommend creating an ad campaign with the same advertiser that you enabled action points for.

2. Create a banner to target by behavior.


## Step 4. Set up targeting by behavior {#step-4}

1. Open the **Campaigns** tab. Next to the campaign name, click ![](../_images/kebab-2.png =15x20) → **Targeting** or select a campaign and go to **Targeting**.
2. Click **Add a targeting condition** and select **By behavior**.
3. At the top, select the type of categories you want to target: temporary or permanent.
4. Set up the logic for applying the conditions:

    - `Combining conditions by Or`: The ad will be served if at least one specified condition is met.

    - `Combining conditions by And`: The ad will be served only if all the conditions are met.
    
5. Set up to 9 targeting conditions. They can be affirmative (`Visited the category pages`) or negative (`Haven't visited the category pages`).

6. Select a category. For an affirmative condition, you can specify additional conditions (the minimum number and duration of views in the category) for marked up users.

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


> **Use cases**
> 
> 
> {% cut "Show a banner (or ad campaign banners) only to users who have already visited the site" %}
> 
> 1. Under **The targeting parameter**, click **Set up a dashboard** next to **By behavior** or select **Add a targeting condition** → **By behavior** if no condition is set.
>
> 1. Go to the **Temprorary categories** tab and select `Combining conditions by And`.
>
> 1. Set **Condition 1** → `Visited the category pages` and select the created temporary category.
>
> 
> {% endcut %}
> 
> {% cut "Serve Banner 1 to users who visit the site (section, page) for the first time and serve Banner 2 to users who have already visited the site" %}
> 
> For Banner 1 (for users who visit the site for the first time):
> 
> 1. Under **The targeting parameter**, click **Set up a dashboard** next to **By behavior** or select **Add a targeting condition** → **By behavior** if no condition is set.
>
> 1. Go to the **Temprorary categories** tab and select `Combining conditions by And`.
>
> 1. Set **Condition 1** → `Haven't visited the category pages` and select the created temporary category.
> 
> For Banner 2 (for users who visited the site), set the reverse condition:
> 
> 1. Under **The targeting parameter**, click **Set up a dashboard** next to **By behavior** or select **Add a targeting condition** → **By behavior** if no condition is set.
>
> 1. Go to the **Temprorary categories** tab and select `Combining conditions by And`.
>  
> 1. Set **Condition 1** → `Visited the category pages` and select the created temporary category.
>     
> 
> {% endcut %}
> 
> {% cut "Serve a banner from Campaign 2 only to users who saw the banner from Campaign 1" %}
> 
> 
> 1. Make sure that there are two or more banners. Banners can belong to different ad campaigns.
> 
> 1. Convert a link to the action point. For example, you previously received a link in the format:
>     
>     ```html
>     <img src="http://ads.adfox.ru/166283/tracePoint?p7=jlzo&p8=b" width="0" height="0" border="0" alt="">
>     ```
>     
>     Remove the `img` and `amp;` tags from the link if there are any. The link should look like this:
>     
>     ```
>     https://ads.adfox.ru/166283/tracePoint?p7=jlzo&p8=b
>     ```
>     
> 1. Open Banner 1, which should be served first. In the banner settings, enter the link of the action point into the **Tracking pixel link** field.
>     
> 1. Open Banner 2, which should be served only to users who saw Banner 1. Go to the **Targeting** tab at the banner level if both banners are in the same ad campaign. If the banners are in different ad campaigns, open the tab at the campaign level. 
>     
> 1. Under **The targeting parameter**, click **Set up a dashboard** next to **By behavior** or select **Add a targeting condition** → **By behavior** if no condition is set.
>
> 1. Go to the **Temprorary categories** tab and select `Combining conditions by And`.
>     
> 1. Set **Condition 1** → `Visited the category pages` and select the created temporary category.
>     
> 
> 
> {% endcut %}
> 
> {% cut "If there are two action tracking points, show the banner to users who saw the first point and stop showing it to those who saw the second one" %}
> 
> 
> Create two categories:
> 
>   - Category 1: With an action point to show the banner.
>   - Category 2: With an action point to stop showing the banner.
>
> Then set up targeting by behavior:
> 
> 1. Under **The targeting parameter**, click **Set up a dashboard** next to **By behavior** or select **Add a targeting condition** → **By behavior** if no condition is set.
>
> 1. Go to the **Temprorary categories** tab and select `Combining conditions by And`.
>     
> 1. Set **Condition 1** → `Visited the category pages` and select Category 1.
>     
> 1. Set **Condition 2** → `Haven't visited the category pages` and select Category 2.
> 1. Click **Change**.
> 
> 
> {% note alert %}
> 
> If the user fulfills the condition to stop serving the banner and then sees the action point with the `Haven't visited the category pages` condition again, the information is erased and the banner is served to this user again.
> 
> {% endnote %}
> 
> 
> 
> {% endcut %}
> 
> {% cut "Serve Banner 2 to users who clicked Banner 1 " %}
> 
> 
> 1. Get a link to the action point that the temporary category is associated with.
> 
> 1. Create Banner 1. We recommend using templates with `HTML5` in the name.
> 
> 1. Open the parameters of the created banner and update them as follows:
>     
>     {% cut "There is an “a” tag in the code" %}
>     
>     Add an `onclick="buttonClick()` function call to the HTML code.
>     
>     For example:
>     
>     ```html
>     <a href="%request.reference_user1%" target="%banner.target%" onclick="buttonClick()">click</a>
>     ```
>     
>     Add the following script anywhere in the banner layout:
>     
>     ```html
>     
>     ```
>
>     Where `LINK_TP` is replaced with an action tracking point link in the format: `https://yandex.ru/ads/adfox/392990/tracePoint?p7=wtvn&p8=b`.
>     
>     {% endcut %}
>     
>     {% cut "There is a callClick() function call in the code" %}
>     
>     Find the `callClick` function in the banner's HTML code and add code with an action tracking point call to it.
>     
>     For example:
>     
>     ```javascript
>     function callClick(n) {
>             var img = new Image();
>             img.src = 'LINK_TP&pr=%system.random%';
>           var link = ( n ? flashVars.events[n] : flashVars.link );
>           window.open(flashVars.reference + "@" + flashVars.link, flashVars.target);
>    }
>     ```
>     
>     Where `LINK_TP` is an action tracking point link in the format: `https://yandex.ru/ads/adfox/392990/tracePoint?p7=wtvn&p8=b`.
>     
>     {% endcut %}
>     
> 1. Create Banner 2, which should be served only to those who clicked Banner 1, and set up targeting by behavior only for users who visited the pages in the temporary category.
> 
> 
> {% endcut %}


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

[*category]: You can use categories to:
- Group sites, sections, or placements by topic and get statistics on impressions and clicks for the entire category.
- Mark up the audience for targeting by behavior.