---
metadata:
  - name: generator
    content: Diplodoc Platform v5.48.2
alternate:
  - https://yandex.com/dev/games/doc/en/sdk/sdk-adv.md
  - https://yandex.com/dev/games/doc/hi/sdk/sdk-adv.md
  - https://yandex.com/dev/games/doc/ko/sdk/sdk-adv.md
  - https://yandex.com/dev/games/doc/ru/sdk/sdk-adv.md
  - https://yandex.com/dev/games/doc/tr/sdk/sdk-adv.md
  - https://yandex.com/dev/games/doc/vi/sdk/sdk-adv.md
  - https://yandex.com/dev/games/doc/zh/sdk/sdk-adv.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/games/doc/en/llms.txt

# Advertising

<!-- source: en/_includes/script-common.md -->
<!-- source: en/_includes/script/index-js.md -->

<!-- endsource: en/_includes/script/index-js.md -->

<!-- source: en/_includes/script/requirements-js.md -->

<!-- endsource: en/_includes/script/requirements-js.md -->

<!-- source: en/_includes/script/image-modal-js.md -->

<!-- endsource: en/_includes/script/image-modal-js.md -->
<!-- endsource: en/_includes/script-common.md -->

You can generate revenue from placing ad units in your games. To do this:
1. Learn about the [tips and recommendations](#recommendations) for ad placement.
1. Set up [ad calls](#settings) using the SDK.
1. [Enable monetization](https://yandex.com/dev/games/doc/en/console/adv-monetization.md) in the Developer Console.

## Tips and recommendations for placing ads {#recommendations}

- Ad calls should be placed in such a way that the user clearly perceives them as ads, not as an actual gameplay element.
- It is recommended to show ads after a user action or on a timer if completing a level takes more than 5 minutes. For more information, see [Ad placement](https://yandex.com/dev/games/doc/en/requirements/4/4.md).
- You can call [rewarded video ads](#rewarded-video) as often as you want.
- The frequency of calling an interstitial ad unit is controlled by [Yandex Games](https://yandex.com/games/){.external}.


{% note alert %}

The Yandex Advertising Network considers incidental user clicks on ad units as ad fraud and reduces revenue from in-game advertising.

To avoid this, do not call ads during gameplay, when users may unintentionally click on the ad unit.

Example of an improper ad call:

```javascript
setInterval(() => ysdk.adv.showFullscreenAdv(), 180000)
```

{% endnote %}


## Interstitial ad {#full-screen-block}

An ad unit that completely covers the app and is shown after certain data requests from the user (for example, when transitioning to the next game level) but before this data is returned.

### ysdk.adv.showFullscreenAdv() {#show-fullscreen-adv}

Call a fullscreen ad unit.

**Method signature**

```typescript showLineNumbers
function showFullscreenAdv(callbacks?: {
    onOpen?: () => void;
    onClose?: (wasShown: boolean) => void;
    onError?: (error: object) => void;
}) => void {}
```

The `callbacks` parameter can include optional callback functions:

#|
|| **Callback function** | **Description** ||
|| `onOpen` | Called when the ad is opened successfully. ||
|| `onClose` | Called when the ad closes, after an error, or after an ad failed to open due to too frequent calls. It's used with the `wasShown` argument (`boolean` type), the value of which indicates whether the ad was shown or not. ||
|| `onError` | Called when an error occurs. The error object is passed to the callback function. ||
|#

#### Example {#full-screen-example}

```javascript showLineNumbers
const ysdk = await YaGames.init();

ysdk.adv.showFullscreenAdv({
    [callbacks](*key_callbacks): {
        [onOpen](*key_onOpen): () => console.log('Ad opened.'),
        [onClose](*key_onClose): (wasShown) => console.log(wasShown ? 'Shown and closed.' : 'Not shown.'),
        [onError](*key_onError): (error) => console.log('Call error.'),
    }
})
```


### Rewarded video {#rewarded-video}

A video ad block that rewards the user for watching it, for example, with in-game currency.

### ysdk.adv.showRewardedVideo() {#show-rewarded-video}

Call a rewarded video ad.

**Method signature:**

```typescript showLineNumbers
function showRewardedVideo(callbacks?: {
    onOpen?: () => void;
    onRewarded?: () => void;
    onClose?: (wasShown: boolean) => void;
    onError?: (error: object) => void;
}) => void {}
```

The `callbacks` parameter can include optional callback functions:

#|
|| **Callback function** | **Description** ||
|| `onOpen` | Called when the video ad is shown on the screen. ||
|| `onRewarded` | Called when a video ad impression is counted. This function should specify a reward for viewing the ad. ||
|| `onClose` | Called when the video ad closes. ||
|| `onError` | Called when an error occurs. The error object is passed to the callback function. ||
|#

#### Example {#rewarded-video-example}

```javascript showLineNumbers
const ysdk = await YaGames.init();

ysdk.adv.showRewardedVideo({
    [callbacks](*key_callbacks): {
        [onOpen](*key_onOpen): () => console.log('Ad opened.'),
        [onRewarded](*key_onRewarded): () => console.log('User received reward.'),
        [onClose](*key_onClose2): (wasShown) => console.log(wasShown ? 'Shown and closed.' : 'Not shown.'),
        [onError](*key_onError): (error) => console.log('Call error.'),
    }
})
```

## Sticky banner {#sticky-banner}

An ad unit that is displayed during the game.

### Enable sticky banner display {#banner-on}

1. Open the [Developer Console](https://games.yandex.com/console){.external} and go to the **Advertising** tab.
1. In the **Sticky banners** section, set up the display of banners:
   - For mobile devices:

      - **Sticky banner in portrait orientation**: Select the **At the bottom** or **At the top** position.
      - **Sticky banner in landscape orientation**: Select the **At the bottom**, **At the top**, or **On the right** position.

   - For computers: Enable the **Sticky banner on the desktop** option. The banner will be displayed on the right.

### Manage sticky banner display {#banner-adv}

By default, the sticky banner appears upon launch and remains visible throughout the entire session. To manage sticky banner display using SDK methods, in the [Developer Console](https://games.yandex.com/console){.external} on the **Advertising** tab, enable the **Use the API to display a sticky-banner** option.

#### ysdk.adv.getBannerAdvStatus() {#get-banner-adv-status}

Get the current status of the sticky banner.

**Method signature**

```typescript showLineNumbers
function getBannerAdvStatus(): Promise<{
    stickyAdvIsShowing: boolean;
    reason?: 'ADV_IS_NOT_CONNECTED' | 'UNKNOWN';
}> {}
```

Returns the sticky banner display status `stickyAdvIsShowing`. If the banner is not shown, it also returns the optional `reason` field, which indicates why the banner is not displayed:

#|
|| **Reason** | **Description** ||
|| `ADV_IS_NOT_CONNECTED` | Banners are not enabled. ||
|| `UNKNOWN` | Error displaying ads on the Yandex side. ||
|#

#### ysdk.adv.showBannerAdv() {#show-banner-adv}

Show the sticky banner.

Method signature:

```typescript showLineNumbers
function showBannerAdv(): Promise<{
    stickyAdvIsShowing: boolean;
    reason?: 'ADV_IS_NOT_CONNECTED' | 'UNKNOWN';
}>
```

Returns values are similar to [ysdk.adv.getBannerAdvStatus()](#get-banner-adv-status).

#### ysdk.adv.hideBannerAdv() {#hide-banner-adv}

Hide the sticky banner.

**Method signature**

```typescript showLineNumbers
function hideBannerAdv(): Promise<{
    stickyAdvIsShowing: boolean;
}>
```

Returns the sticky banner display status `stickyAdvIsShowing`.

#### Example {#sticky-banner-example}

```javascript showLineNumbers
const ysdk = await YaGames.init();

const { stickyAdvIsShowing , reason } = await ysdk.adv.getBannerAdvStatus();

if (stickyAdvIsShowing) {
    // Ad is displayed.
} else if (reason) {
    // Ad is not displayed.
    console.log(reason);
} else {
    ysdk.adv.showBannerAdv();
}
```

---

<!-- source: en/_includes/sdk-support.md -->
{% note info %}

Our support team can help publish finished games on Yandex Games. If you have any questions about development or testing, ask them in the [Discord channel](https://discord.com/invite/wU4p3whr4T){.external}.

{% endnote %}

If you are facing an issue or have a question regarding the use of Yandex Games SDK, please contact support:

<!-- source: en/_includes/button-chat.md -->
<a href="https://yandex.com/chat/#/user/a4fa5c06-75db-9b38-6eea-b1673785f7d5">
  <span class="button">Write to chat</span>
</a>
<!-- endsource: en/_includes/button-chat.md -->
<!-- endsource: en/_includes/sdk-support.md -->

[*key_callbacks]: `callbacks`: Optional callback functions. They are configured individually for each ad unit.

[*key_onOpen]: `onOpen`: Called when a video ad is displayed on the screen.

[*key_onRewarded]: `onRewarded`: The function called when a video ad impression is counted. Specify, in this function, the reward the user will receive after viewing.

[*key_onClose]: `onClose`: Called when the ad is closed, on error, or if the ad failed to open due to too frequent calls. It's used with the `wasShown` argument (`boolean` type), which indicates whether the ad was shown or not.

[*key_onClose2]: `onClose`: Called when a user closes a video ad.

[*key_onError]: `onError`: Called when an error occurs. The error object is passed to the callback function.