Ad management

You can generate revenue from placing ad units in your games. To do this:

  1. Learn about the tips and recommendations for ad placement.
  2. Set up ad calls using the SDK.
  3. Enable monetization in the Yandex Games Console.

Tips and recommendations for placing ads

  • Ad calls should be placed in such a way that the user clearly perceives them as ads, not as an actual gameplay element.
  • Recommended timings for calling ads in the game: before the game starts, during level transitions, and after losing.
  • You can call rewarded video ads as often as you want.
  • The frequency of calling an interstitial ad unit is controlled by Yandex Games.

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:

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

Configure ad calls

Interstitial ad

Interstitial ad units completely cover the app background and are shown after certain data requests from the user (for example, when transitioning to the next game level) but before this data is returned.

To call an ad, use the ysdk.adv.showFullscreenAdv({callbacks:{}}) method.

callbacks: Optional callback functions. They are configured individually for each ad unit.

  • 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.

  • onOpen: Called when the ad is opened successfully.

  • onError: Called when an error occurs. The error object is passed to the callback function.

  • onOffline: Called when the network connection is lost (switching to offline mode).

Example

ysdk.adv.showFullscreenAdv({
    callbacks: {
        onClose: function(wasShown) {
          // An action on ad closing.
        },
        onError: function(error) {
          // An action in case of an error.
        }
    }
})

Rewarded videos

Rewarded videos are ad units for in-game monetization. that users can view in exchange for certain rewards or in-game currency.

To call an ad, use the ysdk.adv.showRewardedVideo({callbacks:{}}) method.

callbacks: Optional callback functions. They are configured individually for each ad unit.

  • onClose: Called when the video ad closes.

  • onOpen: Called when the video ad is shown on the screen.

  • onError: Called when an error occurs. The error object is passed to the callback function.

  • onRewarded: Called when a video ad impression is counted. This function should specify a reward for viewing the ad.

Example

ysdk.adv.showRewardedVideo({
    callbacks: {
        onOpen: () => {
          console.log('Video ad open.');
        },
        onRewarded: () => {
          console.log('Rewarded!');
        },
        onClose: () => {
          console.log('Video ad closed.');
        },
        onError: (e) => {
          console.log('Error while open video ad:', e);
        }
    }
})

Sticky banner

To enable a sticky banner:

  1. Open the Games Console and go to the Advertising tab.
  2. Go to Sticky banners and set up the display of banners:
    • For mobile devices:

      • Sticky banner in portrait orientation: Select the banner's position — At the bottom or At the top.
      • Sticky banner in landscape orientation: Select the banner's position — At the bottom, At the top, or On the right.
    • For computers: Enable the Sticky banner on the desktop option. The banner will be displayed on the right.

By default, the sticky banner appears upon launch and remains visible throughout the entire session. To configure the time for displaying the banner:

  1. Under Sticky banners, enable the Use the API to display a sticky-banner option.
  2. Set up banner display using the following methods:
    • ysdk.adv.getBannerAdvStatus(): Shows the status of the banner.
    • ysdk.adv.showBannerAdv(): Calls the banner.
    • ysdk.adv.hideBannerAdv(): Hides the banner.

These methods return the value stickyAdvIsShowing: boolean. If stickyAdvIsShowing = false, the ysdk.adv.getBannerAdvStatus() and ysdk.adv.showBannerAdv() methods might return the optional reason field with the following possible reasons:

  • ADV_IS_NOT_CONNECTED: Banners are not enabled.
  • UNKNOWN: Error displaying ads on the Yandex side.

Example

ysdk.adv.getBannerAdvStatus().then(({ stickyAdvIsShowing , reason }) => {
    if (stickyAdvIsShowing) {
        // A sticky banner is shown.
    } else if(reason) {
        // A sticky banner is not shown.
        console.log(reason)
    } else {
        ysdk.adv.showBannerAdv()
    }
})

Note

Our support team can help publish finished games or WebApps on Yandex Games. If you have any questions about development or testing, ask them in the Discord channel.

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

Write to chat
Previous
Next