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

# Ad unit code features

You can enable additional functions and change certain settings by directly editing the code of the ad unit.

The `Ya.Context.AdvManager.render` function is responsible for invoking the ad in the code.


{% note alert %}

- If you do not have sufficient experience working with ad tags, we don't recommend making changes to the ad unit tag. Changes to any variables or functions other than those described on this page might lead to errors in Yandex Advertising Network ad units and cause you to lose revenue.

- You can't use the unit code as an alternative code in other advertising systems.

{% endnote %}


## Statistical cross-sections {#statId}

You can also specify sample IDs in the unit code and collect separate statistics for each sample. The sample ID is stored in a separate variable:

Variable name | Description | Data type
----- | ----- | -----
`statId` | Sample ID | A number between 1 and 1,000,000,000


Enter the sample ID in the ad tag to be placed on the site. For example:

```javascript
Ya.Context.AdvManager.render({
    blockId: "R-A-123456-1",
    renderTo: "yandex_rtb_R-A-123456-1",
    statId: 34567, // CROSS SECTION ID
});
```

For the unit `R-A-123456-1` from the example, the sample ID is `34567`. It can also be specified in other units. This will allow you to view group statistics for these units. By placing the `R-A-123456-1` unit on other pages, you can specify a different sample ID to view statistics separately for each placement.

## Limiting banner height {#max-height}

By default, [Adaptive](https://yandex.com/support/partner/en/web/units/formats/main.md#adaptive) <svg width="22" height="15" viewBox="0 0 22 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 3C0 1.34315 1.34315 0 3 0H19C20.6569 0 22 1.34315 22 3V12C22 13.6569 20.6569 15 19 15H3C1.34315 15 0 13.6569 0 12V3Z" fill="#E7CBFF"/><path d="M5.76 8.63H4.24C4.23333 9.07 4.31333 9.45 4.48 9.77C4.64667 10.09 4.87 10.3533 5.15 10.56C5.43667 10.7667 5.76333 10.9167 6.13 11.01C6.50333 11.11 6.88667 11.16 7.28 11.16C7.76667 11.16 8.19333 11.1033 8.56 10.99C8.93333 10.8767 9.24333 10.72 9.49 10.52C9.74333 10.3133 9.93333 10.07 10.06 9.79C10.1867 9.51 10.25 9.20667 10.25 8.88C10.25 8.48 10.1633 8.15333 9.99 7.9C9.82333 7.64 9.62333 7.43333 9.39 7.28C9.15667 7.12667 8.92 7.01667 8.68 6.95C8.44667 6.87667 8.26333 6.82667 8.13 6.8C7.68333 6.68667 7.32 6.59333 7.04 6.52C6.76667 6.44667 6.55 6.37333 6.39 6.3C6.23667 6.22667 6.13333 6.14667 6.08 6.06C6.02667 5.97333 6 5.86 6 5.72C6 5.56667 6.03333 5.44 6.1 5.34C6.16667 5.24 6.25 5.15667 6.35 5.09C6.45667 5.02333 6.57333 4.97667 6.7 4.95C6.82667 4.92333 6.95333 4.91 7.08 4.91C7.27333 4.91 7.45 4.92667 7.61 4.96C7.77667 4.99333 7.92333 5.05 8.05 5.13C8.17667 5.21 8.27667 5.32 8.35 5.46C8.43 5.6 8.47667 5.77667 8.49 5.99H10.01C10.01 5.57667 9.93 5.22667 9.77 4.94C9.61667 4.64667 9.40667 4.40667 9.14 4.22C8.87333 4.03333 8.56667 3.9 8.22 3.82C7.88 3.73333 7.52333 3.69 7.15 3.69C6.83 3.69 6.51 3.73333 6.19 3.82C5.87 3.90667 5.58333 4.04 5.33 4.22C5.07667 4.4 4.87 4.62667 4.71 4.9C4.55667 5.16667 4.48 5.48333 4.48 5.85C4.48 6.17667 4.54 6.45667 4.66 6.69C4.78667 6.91667 4.95 7.10667 5.15 7.26C5.35 7.41333 5.57667 7.54 5.83 7.64C6.08333 7.73333 6.34333 7.81333 6.61 7.88C6.87 7.95333 7.12667 8.02 7.38 8.08C7.63333 8.14 7.86 8.21 8.06 8.29C8.26 8.37 8.42 8.47 8.54 8.59C8.66667 8.71 8.73 8.86667 8.73 9.06C8.73 9.24 8.68333 9.39 8.59 9.51C8.49667 9.62333 8.38 9.71333 8.24 9.78C8.1 9.84667 7.95 9.89333 7.79 9.92C7.63 9.94 7.48 9.95 7.34 9.95C7.13333 9.95 6.93333 9.92667 6.74 9.88C6.54667 9.82667 6.37667 9.75 6.23 9.65C6.09 9.54333 5.97667 9.40667 5.89 9.24C5.80333 9.07333 5.76 8.87 5.76 8.63ZM13.2541 9.68V5.18H14.3741C14.7608 5.18 15.0841 5.23667 15.3441 5.35C15.6108 5.45667 15.8241 5.61333 15.9841 5.82C16.1441 6.02667 16.2575 6.27667 16.3241 6.57C16.3975 6.85667 16.4341 7.18 16.4341 7.54C16.4341 7.93333 16.3841 8.26667 16.2841 8.54C16.1841 8.81333 16.0508 9.03667 15.8841 9.21C15.7175 9.37667 15.5275 9.49667 15.3141 9.57C15.1008 9.64333 14.8808 9.68 14.6541 9.68H13.2541ZM11.6841 3.86V11H14.7641C15.3108 11 15.7841 10.91 16.1841 10.73C16.5908 10.5433 16.9275 10.29 17.1941 9.97C17.4675 9.65 17.6708 9.27 17.8041 8.83C17.9375 8.39 18.0041 7.91 18.0041 7.39C18.0041 6.79667 17.9208 6.28 17.7541 5.84C17.5941 5.4 17.3675 5.03333 17.0741 4.74C16.7875 4.44667 16.4441 4.22667 16.0441 4.08C15.6508 3.93333 15.2241 3.86 14.7641 3.86H11.6841Z" fill="#5B2DB2"/></svg> combinatorial ads automatically occupy 100% of the parent container. You can adjust the unit height using the `height` and `max-height` parameters.

Recommended values for the maximum unit height:

- Minimum of 70 and maximum of 90 vh for the mobile version.

- Minimum of 40 and maximum of 60 vh for the desktop version when placed on side panels.

Example of a code for an ad unit with a maximum height:

```html
<div id="yandex_rtb_R-I-677833-1" style="max-height: 80vh;">
  <div style="height: 72vh;"></div>
</div>

```

## Setting up a theme {#theme}

You can set a theme (light or dark) in the Yandex Advertising Network interface when creating or editing a unit. You can also manage the unit theme via the ad tag using the `darkTheme` parameter:

- `darkTheme: false`: Light theme is used.

- `darkTheme: true`: Dark theme is used. Dark theme units have a different background and color scheme for their text, border, buttons, and other elements.

When adding the `darkTheme` parameter, the theme settings specified in the interface are ignored.

Managing the unit theme through the code is convenient for dynamic theme sites. For example, you can use JavaScript to set different `darkTheme` parameter values: depending on the time of day or the site or browser theme chosen by the user.

Example of a code for an ad unit with a dark theme:

```javascript
Ya.Context.AdvManager.render({
    blockId: "R-A-123456-1",
    renderTo: "yandex_rtb_R-A-123456-1",
    darkTheme: true
});
```


{% cut "Example of a Top Ad unit with a dark theme" %}

![](../../_images/top-ad-dark.png)

{% endcut %}


## Placing a Floor Ad or Top Ad simultaneously with a Feed {#feed}

You can't display a [Feed](https://yandex.com/support/partner/en/web/units/types/feed.md), a [Floor Ad](https://yandex.com/support/partner/en/web/units/types/floor-ad.md), and a [Top Ad](https://yandex.com/support/partner/en/web/units/types/top-ad.md) on the same screen. Configure the `observer` callback function to delete your Floor Ad or Top Ad unit when the Feed becomes visible.

**Example of an ad code with the “observer” function**

```javascript
    <div id="yandex_rtb_R-A-588461-101"></div>
    
```

## Callback functions in the ad tag {#rtb-code-tuning-callback}

You can add the following callback functions to the ad code:

#### onClose
 
:   To find out at what point the ad was closed, add the `onClose` callback function when placing the unit. This function is available for fullscreen, Top Ad, and Floor Ad units.

    You can set which action to call after the banner is closed based on your business logic. For example, this action may be to call another ad unit. To do this, enter the code with the action in `onClose`.


    {% cut "Example tag for calling an ad with the onClose function" %}


    ```javascript
    <!-- Yandex.RTB R-A-588461-68 -->
    
```


{% endcut %}

{% cut "Example of an ad code for the second ad unit" %}


```javascript
<div id="yandex_rtb_R-A-123456-1-2"></div>

```


{% endcut %}

## Experiments on ads with Varioqub {#varioqub}

<!-- source: en/_includes/efficiency/varioqub.md -->
You can conduct experiments on ads placed on your site using Varioqub. This tool allows you to create an experiment with multiple options, changing the elements and layout of the site and comparing different ad units and their settings. As a result of your experiment, you get statistics for indicators that help determine the most effective option in terms of monetization and user metrics. For more information, see [Varioqub experiments](https://yandex.com/support/varioqub/ads.html) in the Help section.
<!-- endsource: en/_includes/efficiency/varioqub.md -->

## Page context collection for ad targeting {#page-context}

Only text content visible to the user is analyzed for context. This feature can't be used to collect users' personal data. Ad tags don't analyze hidden fields, input forms, passwords, payment details, or information that isn't visible to the user on the page.

Collected context is used only for contextual ad targeting, such as to identify page categories, key topics, or the overall content subject.

#### Recommendation {#page-context-recommendations}

We recommend turning off page context collection if your ad placements are located on pages that may display private or sensitive data that you prefer not to use for targeting purposes.

This includes pages such as personal accounts, private messages, orders, support tickets, and pages that display medical, financial, or other sensitive information.

#### Turn off context collection {#page-context-disable}

You can turn off page context collection using the `disableGrab` parameter in your ad tag:

```js
Ya.Context.AdvManager.render({
    blockId: "R-A-123456-1",
    renderTo: "yandex_rtb_R-A-123456-1",
    disableGrab: true
});
```

Even with this feature turned off, your ad unit will still work normally, but the page text will no longer be analyzed or used for contextual ad targeting.

## Contact support

If you didn't find the information you were looking for, check the FAQs or contact us.


{% cut "I inserted code but the ads are not being displayed" %}


There are several reasons why problems displaying ads may occur:

- **The ad tag has recently been installed.** The [Yandex Advertising Network robot](https://yandex.com/support/partner/en/technologies/robot.md) requires some time to index the page and link it to ads.

- **The ad code is installed incorrectly.** Make sure that your JavaScript code for calling ad units has been installed correctly. Don't change the tag when copying it. When copying the tag, your text editor might truncate or wrap long strings, which might cause the JavaScript code to run incorrectly.

- **Tag invalid for the site.** Make sure that the installed ad unit code was created for this site and not for one of your other sites.

- **Site is blocked from indexing.** The site must be accessible for indexing by the [Yandex Advertising Network robot](https://yandex.com/support/partner/en/technologies/robot.md), `YandexDirect`. If indexing a site or its individual pages is banned (for example, in the `robots.txt` file), the robot can't index the content of the pages or select relevant ads for them.

- **Text is wrapped in the `<noindex>`** tag. Make sure that the page has text on it and that it has not been excluded using the `<noindex>` tag. You can't select theme-based ads for pages that have no text.

- **The information in the browser cache is old.** Refresh the page by pressing **Ctrl + F5** (Windows) or **Command + R** (Mac).



{% endcut %}

<!-- source: en/_includes/feedback-forms/units-buttons.md -->


<details>
    <summary class="button">Write to WhatsApp</summary>
    <img src="https://yastatic.net/s3/doc-binary/src/support/partner/qr-codes/gr-code-en-new.svg" style="width: 100%; display: block;"/>
    <a href="https://wa.me/74952583554?utm_source=yan&utm_medium=help&utm_campaign=en" style="display: block; text-align: left; margin-left: 18px; color: #5889FF;">Go to WhatsApp</a>
</details>

<details>
    <summary class="button">Write to Telegram</summary>
    <img src="https://yastatic.net/s3/doc-binary/src/support/partner/en/qr-codes/qr-code-en-telegram.svg" style="width: 100%; position: relative; left: -18px; display: block;"/>
    <a href="http://t.me/YanSupport_Bot" style="display: block; text-align: left; margin-left: 18px; color: #5889FF;">Go to Telegram</a>
</details> 


<a href="https://yandex.ru/chat?context=%7B%22entrypoint%22%3A%22%7B%5C%22entrypoint%5C%22%3A%5C%22help%5C%22%2C%5C%22a_pagename%5C%22%3A%5C%22partner-en%5C%22%7D%22%7D#/user/00155607-f40f-9af8-7910-84a29fd95914"> <!--ссылка, куда ведет кнопка. Если внутренняя ссылка, пишем без .md и .html --> 
  <span class="button">Write to chat</span> <!--текст на кнопке--> 
</a>


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



<!-- source: en/_includes/feedback-forms/button-style.md -->

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

<div width="100%" align="center"> 
<br><br>
You can also go to
<br><br>

[![](https://yastatic.net/s3/doc-binary/src/support/mobile-ads/en/logo/rsya.svg)](https://partner.yandex.com)

</div>

<div><br><br></div>
<div class="container" style="padding: 0;">
  <div class="column">
      <p style="font-size: large;">Useful links</p>
      <ul>
         <li><a href="https://t.me/YANpartner/" target="_blank">Yandex Advertising Network Telegram channel</a></li>
         <li><a href="https://yandex.ru/legal/partner/" target="_blank">Rules of participation</a></li>
         <li><a href="https://yandex.com/legal/yan_service_offer/" target="_blank">Yandex Advertising Network Terms of Offer</a></li>
      </ul>
  </div>   
</div>
<div><br><br></div>


<!-- endsource: en/_includes/feedback-forms/units-buttons.md -->
