Thumbnail Ad
This article will go through all the steps required to display a Thumbnail Ad in your application.
Thumbnail Ads are small rectangle ads that are displayed as overlays to your application content. They are closable and draggable by the user, and can be used to (i) monetize your application through new incremental inventories and (ii) push cross-promotion campaigns.
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 Thumbnail 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: Thumbnail Ad on Unity 2018+ versions
If you encounter a black video instead of a normal video playback, this is due to the missinghardwareAccelerated
property in the Android manifest. This is required to play HTML5 videos.
[Android] Add hardwareAccelerated property in the Android manifest
Create the following class in the path Assets/Editor
When you build the project, the script will automatically modify the Android manifest and the video will playback correctly.
Step 3: Load a Thumbnail Ad
The Ogury SDK provides the OguryThumbnailAd
object that lets you load, display and control your Thumbnail Ad.
Instantiate a Thumbnail Ad
Declare an
OguryThumbnailAd
instance variable in theActivity
where you want to display a Thumbnail Ad:
In the
Start
method of your scene, instantiate the Thumbnail Ad:
OguryThumbnailAd
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.
Load a Thumbnail Ad
To start loading an ad, call the Load
method:
The ad is loaded with a default max size of 180x180dp(Android)/points(iOS). The max size can be changed by following the instructions in this section.
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 theInitialize
method of your other script:
Additionally, if you want to follow the lifecycle of the Thumbnail Ad, you can register to events.
Step 4: Show a Thumbnail Ad
To display the ad, call the Show
method:
Thumbnail Ads are displayed bottom-right aligned, with a margin of 20 dp on the right and 20 dp on the bottom. More details on how to set the thumbnail position can be found in this section.
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.
By default the Thumbnail Ad remains on screen while the user is navigating between activities(Android)/View Controllers(iOS) of your application.
You can customize where Thumbnail Ads are displayed in this section.
Step 5: 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 Thumbnail Ad, we recommend you to log every events on your OguryThumbnailAd
to follow the lifecycle of the Thumbnail 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
Customize Thumbnail Ad size
To customize the size of the Thumbnail Ad, replace your call to the Load
method by the following:
maxWidth
and maxHeight
parameters define the maximum size that the Thumbnail Ad will take on the screen. Both values are in dp(Android)/points(iOS).
We recommend to use maxWidth
= 180 and maxHeight
= 180 to improve the readability of the content of the Thumbnail Ad.
Example: when given maxWidth
= 180 and maxHeight
= 180, the Ogury SDK may decide to display a 16:9 video ad inside. In this case the Thumbnail Ad size will be 180x102 to match the ratio of the 16:9 video.
The following constraints apply on the values you can pass to these parameters:
maxWidth
andmaxHeight
must not be greater than the size of the screen.maxWidth
andmaxHeight
must be greater than or equal to 101.longest side, either
maxWidth
ormaxHeight
, must be greater than or equal to180.
Check if an ad is ready to be displayed
Call the following method to check if an Thumbnail 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.
Customize Thumbnail Ad position
To customize the position where the Thumbnail Ad is displayed, replace your call to the Show
method by the following:
The Show
method takes the following parameters:
gravity
: the corner based on which the Thumbnail Ad will be positioned and it can have the following values:OguryThumbnailAdGravity.TopLeft
OguryThumbnailAdGravity.TopRight
OguryThumbnailAdGravity.BottomLeft
OguryThumbnailAdGravity.BottomRight
Customize in which page Thumbnail Ad is displayed
Thumbnail Ad remains on screen while the user navigates across the page of your application.
By default, a Thumbnail Ad is displayed in an Activity
only if the two first packages of its classname match the two first packages of the classname of the Activity
passed as parameter to the show
method.
Example: If you pass com.ogury.game.GameActivity
as parameter of the show
method, the Thumbnail Ad will stay on screen in all the activities in the com.ogury
package and all packages at any level under it.
You can override these default settings using whitelists and blacklists.
[Android] Whitelist packages
You can increase the number of whitelisted packages where Thumbnail Ads are displayed and stay on screen. This can be useful if you have Activity
provided by a library like a game engine, in this case you need to whitelist the package associated to this library.
Call the SetWhitelistPackages
method to whitelist packages:
[iOS] Whitelist bundles
You can increase the number of whitelisted bundles where Thumbnail Ads are displayed and stay on screen. This can be useful if you have ViewController
provided by a library like a game engine, in this case you need to whitelist the bundle associated to this library.
Call the SetWhitelistBundleIdentifiers
method to whitelist bundles:
[Android] Blacklist activities
You can prevent Thumbnail Ads from being displayed on a given Activity
by using the SetBlacklistActivities
method:
[iOS] Blacklist View Controllers
You can prevent Thumbnail Ads from being displayed on a given ViewController
by using the setBlacklistViewControllors
method:
When the user navigates to an ViewController
that is not in a whitelisted bundle or that is explicitly blacklisted, the Thumbnail Ad is hidden and paused. It comes back on the screen when the user navigates back to a ViewController
that is allowed.
Events
The Ogury SDK provides events to listen to the lifecycle of a Thumbnail Ad instance.
To register to an event, add the following code just after instantiating the OguryThumbnailAd
:
The OguryThumbnailAd
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 Thumbnail 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