In-game video ads

Attention! Video ads are not intended to be used to advertise your app. It is a different way to monetize non-paying players of your game

On Odnoklassniki there does exist another way to monetize non-paying players of you game via special video advertisements.

By using our API developer can get a video ad for displaying it to a non-paying player and grant him some in-game currency or other bonuses in case of a successful ad view.

Video ads are supported for all HTML applications and MOBILE_HTML applications.

Video ads in HTML games

To implement video ads in your HTML game it must use our javascript SDK.

To display an ad to your player follow these two steps:

  1. Make sure that video ad is available for current user with SDK-method ui.prepareMidroll.
    • If method responded without an error ad is ready to be shown to a user. Only after this you can show user an invitation to view an ad in your UI.
    • If an error occurred when method was invoked then it is most likely that no ads are available to be shown to current user. Retry getting an ad after some time. UI invitation to view an ad should not be shown when there is no prepared video to play.
    • We highly recommend to renew prepared video ad every 5 or so minutes since a prepared video can be expired.
  2. If user agreed to view an ad to initiate this process you need to use SDK-method ui.showMidroll.
    • If video is indeed prepared, it will be shown to user. It will be shown on top of the game’s UI and game itself will be faded.
    • After video is viewed you’ll get response from API (callback).
    • It’s important to know that in case of user navigating to another browser window or closing browser an ad will be stopped from playing. It will only continue playing if browser window is opened and active.

Video ads in MOBILE_HTML games

Ads for MOBILE_HTML games are mostly similar to HTML games but an additional step must be executed to display an ad to a player: you need to ad a frame with special widget to the game’s page before invoking SDK-methods.

Widget needs to be added as a separate iframe and can be opened like this:

https://connect.ok.ru/dk?st.cmd=WidgetVideoAdv&st.app={application_id}&st.sig={signature}&st.call_id=1&st.session_key={session_key}

ParameterRequiredDescription
st.appYesApplication id
st.sigYesRequest signature: md5(“call_id=1” + sessionSecretKey)
st.session_keyYesUser’s session key
st.call_idYesParameter’s value should be “1”

When widget is successfully added to the game’s page process of displaying a video ad is same as for HTML games

Test application

If you want to check how video ads are working for both HTML and MOBILE_HTML applications you can use our test application:

To view an add do the following:

  • press a button “prepare midroll”;
  • press a button “show midroll”.

For MOBILE_HTML app:

  • press a button “inject frame”;
  • press a button “prepare midroll”;
  • press a button “show”.

Statistics

Ad is counted as viewed only if:

  • it was played for a at least 10 seconds;
  • a response “showMidroll$ok$complete” was returned after an ad was played.

If you have any questions about how to implement video ads in our game, how they work or how the statistics are counted you can sent an email with your question to api-support@ok.ru.