Opt-in Video Ad
This article will go through all the steps required to display an Opt-in Video ads in your application.
Opt-in Video Ads are skippable fullscreen videos. They allow you to reward users with in-app items for watching video ads.
Opt-in Video Ads can only be served to users who explicitly and previously chose to view a rewarded ad. You can specify the reward values associated with the Ad units in your application and set different rewards for different Ad units.
Once configuration is done, users start receiving the reward for viewing the video ads without needing to install anything on their device.
Requirements
You have registered an application on your Ogury Dashboard. If not, please refer to the Getting Started section before the next steps.
Step 1: Create Opt-in Video Ad ad units
In case you publish your application on Android and iOS, you should do the following steps twice, once for the Android application and once for the iOS application. Otherwise just select the platform you publish for.
In all the following code samples, we will refer to:
the Ad unit id for the Android application by using the string
ANDROID_AD_UNIT_ID
.the Ad unit id for the iOS application by using the string
IOS_AD_UNIT_ID
.
Step 2: Load an Opt-in Video Ad
The Ogury SDK provides the OguryOptinVideoAd
object that lets you load, display and control your Opt-in Video Ads.
Instantiate an Opt-in Video Ad
Declare a
OguryOptinVideoAd
instance variable in the Scene where you want to display an Opt-in Video Ad:
In the
Start
method of your scene, instantiate the Opt-in Ad:
OguryOptinVideoAd
takes the following parameters:
the Ad unit id for the Android application. You can use
null
if your application is not available on Android.the Ad unit id for the iOS application. You can use
null
if your application is not available on iOS.
Register an event to reward the user
To reward your users when they watched the video, you need to register to the OnAdRewarded
event just after the instantiation of the OguryOptinVideoAd
:
The OguryRewardItem
object has two string
properties:
name:
Name
value:
Value
You can set their values in the Reward setting section.
The Ogury SDK exposes other events to follow the lifecycle of an Opt-in Video Ad. You can find their description in the Events section.
Load an Opt-in Video Ad
To start loading an ad, call the Load
method:
Since it may take a few seconds to fetch the ad resources (video, image, ...) from the network, you should call the Load
method as soon as possible after getting the user's consent.
Ideally, you should implement one of the two following examples depending on your use case:
Call the
Load
method right after theInitialize
method in the script that also collects the consent:
Call the
Load
method in theStart
method of your other script:
Additionally, if you want to follow the lifecycle of the Opt-in Video Ad, you can register to events.
Step 3: Show an Opt-in Video Ad
To display the ad, call the Show
method:
If the method fails to show the ad, one of the following events is triggered:
OnAdNotLoaded
: if the ad was not fully loaded whenShow
was called.OnAdError
: if another error occurred. Error codes are explained below.
Step 4: Test your integration
Ogury exclusively serves ads to users who have given consent. It is essential to have responded to a valid TCFv2 consent form before conducting any tests.
As our algorithm works with personified targeting, you may not receive any ad while testing your application.
You can test your integration by adding the suffix _test
to your interstitial ad unit id, for more details go to Test your implementation page.
Note that if you have just registered your application in the Ogury Dashboard, it will take around 15 minutes until you can successfully load an ad.
If you are not able to display any Opt-in Video Ad, we recommend you to log every events on your OguryOptinVideoAd
to follow the lifecycle of the Opt-in Video Ad:
If you encounter the
OnAdError
event, you can check the error codes section below to understand the error and get some advice on how to solve the issue.If you encounter the
OnAdNotAvailable
event, you can check the test ad section to learn how to display test ads in your application.
Advanced Topics
Check if an ad is ready to be displayed
Call the following method to check if an Opt-in Video Ad is ready to be displayed:
If you want to be informed when the ad is ready to be displayed, you can also register to the OnAdLoaded
event.
Events
The Ogury SDK provides events to listen to the lifecycle of an Opt-in Video Ad instance.
To register to an event, add the following code just after instantiating the OguryOptinVideoAd
:
The OguryOptinVideoAd
exposes the following events:
Error codes
When an ad fails to load or to be displayed, the SDK will trigger the OnAdError
event with an OguryError
as additional parameter. The OguryError
provides the ErrorCode
property to retrieve the error code:
Error codes related to Opt-in Video Ad are defined in the OguryAdsErrorCode
class:
The OguryError
may provide additional details for the issue. You can access them using following property:
Integration Sample
Checkout our sample applications in our GitHub repository :
Last updated