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.
Unlike our other ad formats, there is no equivalent ad format out-of-the-box in Google Ad Manager mediation. To integrate Thumbnail Ads, the Ogury SDK uses Google Mobile Ads custom events to present them as banner to the mediation.
You must create a dedicated Google Ad Manager banner banner ad unit and mediation group for the Thumbnail Ad in order to prevent undesired side-effect (blank banner, etc.).
You have registered an application on your Ogury Dashboard. If not, please refer to the Getting Started section before the next steps.
- Click on the Monetization settings line in the left-menu.
- Copy the Ad unit id as you will need this information later to finish the integration.
In all the following code samples, we will refer to this Ad unit id by using the string
AD_UNIT_ID
.- Go to the list of Ad units and click on the New ad unit button.
- Configure the ad unit as following:
- Set the Name of the ad unit: ex. Thumbnail Ad.
- Set a Code for the integration.
- Select Fixed size as Size mode.
- In Sizes, select the different sizes of Thumbnail Ad you will use in your app.
- In Refresh rate, select No refresh.
We recommend to use 200x200 to improve the readability of the content of the Thumbnail Ad.
We recommend to disable auto-refresh to avoid having Thumbnail Ads popping in front of the user every X seconds.

The following constraints apply the Size you can choose:
- width and height must be greater than or equal to 45dp.
- longest side, either width and height, must be greater than or equal to 80dp.
In order to display Ogury Thumbnail Ad through Google Ad Manager mediation, you need to configure a Custom Event for Ogury in a dedicated yield group.
- Click on Delivery > Yield groups in the left-menu of your Google Ad Manager dashboard.
- Click on New yield group.
- Configure the Details of the yield group as following:
- Set the Name of the yield group: ex. Thumbnail Ad iOS.
- Set the Status as Active.
- Select Banner as Ad format.
- Select Mobile app as Inventory type.

- Scroll to the Targeting section.
- Unfold the Inventory size section.
- Click on the checkbox next to this size to select it.

- Unfold the Inventory section.
- Click on the arrow next to Ad units.
- Search for the ad units where you will display a Thumbnail Ad.
- Click on the check mark to include them in the targeting.

- Scroll to the Yield partners section at the very bottom of the page:
- Click on Add yield partner.
- Select Ogury under the Yield Partner dropdown.

- In the New yield partner pop-up:
- Select Custom Event as Integration type
- Set up CPM that you agreed with your Ogury Account Manager as Default CPM.
- Under Additional yield partner details:
- Set up Label to match with your Ad unit name on Ogury dashboard (e.g.
Ogury
). This makes it easier for you to track the settings are matching on both sides - Ogury and GAM. - Configure Class Name and Parameter as following:

Class name:
OguryThumbnailCustomEvents
Parameter:
{"assetKey":"ASSET_KEY","adUnitId":"AD_UNIT_ID"}
- Click on SAVE.
You need to change the code to instantiate the banner ad from AdMob as following:
Swift
Objective-C
let thumbnailAd = OguryThumbnailAdForGoogleMobileAds(adUnitId: "YOUR_GAM_AD_UNIT_ID")
OguryThumbnailAdForGoogleMobileAds *thumbnailAd = [[OguryThumbnailAdForGoogleMobileAds alloc] initWithAdUnitId:@"YOUR_GAM_AD_UNIT_ID"];
To start loading an ad, call the
load
method:Swift
Objective-C
self.thumbnailAd.load()
[self.thumbnailAd load];
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 thesetupWithAssetKey
method in theViewController
:
Swift
Objective-C
import UIKit
import OgurySdk
class ViewController: UIViewController {
var thumbnailAd: OguryThumbnailAdForGoogleMobileAds?
override func viewDidLoad() {
super.viewDidLoad()
self.thumbnailAd = OguryThumbnailAdForGoogleMobileAds(adUnitId: "YOUR_GAM_AD_UNIT_ID")
OguryAds.shared()?.setup(withAssetKey: "OGY-XXXXXXXXXXXX") { error in
self.thumbnailAd.load()
}
}
}
#import <UIKit/UIKit.h>
#import <OgurySdk/OgurySdk.h>
#import "OguryThumbnailAdForGoogleMobileAds.h"
@interface ViewController : UIViewController
@property (nonatomic, strong) OguryThumbnailAdForGoogleMobileAds *thumbnailAd;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.thumbnailAd = [[OguryThumbnailAdForGoogleMobileAds alloc] initWithAdUnitId:@"YOUR_GAM_AD_UNIT_ID"];
[[OguryAds shared] setupWithAssetKey:@"OGY-XXXXXXXXXXXX" andCompletionHandler:^(NSError *error) {
[self.thumbnailAd load];
}];
}
@end
- Call the
load
method in theviewDidLoad
of your otherViewController
Swift
Objective-C
override func viewDidLoad() {
super.viewDidLoad()
self.thumbnailAd = OguryThumbnailAdForGoogleMobileAds(adUnitId: "YOUR_GAM_AD_UNIT_ID")
self.thumbnailAd.load()
}
- (void)viewDidLoad {
[super viewDidLoad];
self.thumbnailAd = [[OguryThumbnailAdForGoogleMobileAds alloc] initWithAdUnitId:@"YOUR_GAM_AD_UNIT_ID"];
[self.thumbnailAd load];
}
To display the ad call the show function:
Swift
Objective-C
thumbnailAd.show(in: self)
[self.thumbnailAd showInViewController:self];
Thumbnail Ads are displayed bottom-right aligned, with a margin of 20 points on the right and 70 points on the bottom. More details on how to set the thumbnail position can be found in this section.
By default the Thumbnail Ad remains on screen while the user is navigating between View Controllers of your application. A Thumbnail Ad is displayed in a
ViewController
if bundle identifier of the ViewController
corresponds to the main bundle of application.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 callback on your
thumbnailAd
to follow the lifecycle of the ad:- If you encounter the
oguryAdsThumbnailAdAdError
callback, you can check the error codes section below to understand the error code and get some advice on how to solve the issue.
You may want to show a Thumbnail Ad to a user as soon as they enter your application.
You can achieve this behaviour by using the
oguryAdsThumbnailAdAdLoaded
callback to display the Thumbnail Ad as soon as it is displayable. In the viewDidLoad
of the first ViewController
you can append the following lines:Swift
Objective-C
import UIKit
import OguryAds
class ViewController: UIViewController,OguryAdsThumbnailAdDelegate {
var thumbnailAd: OguryThumbnailAdForGoogleMobileAds?
override func viewDidLoad() {
super.viewDidLoad()
self.thumbnailAd = OguryThumbnailAdForGoogleMobileAds(adUnitId: "YOUR_GAM_AD_UNIT_ID")
self.thumbnailAd?.delegate = self
self.thumbnailAd?.load(with: CGSize(width: maxWidth, height: maxHeight))
}
func didLoad(_ thumbnail: OguryThumbnailAd) {
self.thumbnailAd?.show(in: self)
}
}
#import <UIKit/UIKit.h>
#import <OguryAds/OguryAds.h>
@interface ViewController : UIViewController<OguryAdsThumbnailAdDelegate>
@property (nonatomic,strong) OguryAdsThumbnailAd *thumbnailAd;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.thumbnailAd = [[OguryAdsThumbnailAd alloc] initWithAdUnitID:@"YOUR_GAM_AD_UNIT_ID"];
self.thumbnailAd.thumbnailAdDelegate = self;
[self.thumbnailAd load:CGSizeMake(maxWidth, maxHeight)];
}
- (void)oguryAdsThumbnailAdAdLoaded {
[self.thumbnailAd showInViewController:self];
}
@end
You can also use this snippet to display the Thumbnail Ad when the user reaches a given
ViewController
.In order to control the thumbnail size, call
load
method with maxWidth
and maxHeight
parameters:Swift
Objective-C
self.thumbnailAd.load(with: CGSize(width: maxWidth, height: maxHeight))
[thumbnailAd loadWithSize:CGSizeMake(maxWidth, maxHeight)];
maxWidth
and maxHeight
parameters define the maximum size that the Thumbnail Ad will take on the screen. Both values are in points.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 180x101 points to match the ratio of the 16:9 video. The following constraints apply on the values you can pass to these parameters:
To set the Thumbnail Ad position, call the
show
method with OguryRectCorner
and OguryOffset
parameters:Swift
Objective-C
self.thumbnailAd.setOguryRectCorner(rectCorner, offset: OguryOffset(x: xMargin, y: yMargin))
[self.thumbnailAd setOguryRectCorner:rectCorner offset:OguryOffsetMake(xMargin, yMargin)];
The
show
method takes the following parameter:rectCorner
: the corner based on which the Thumbnail Ad will be positioned. TheOguryRectCorner
enum has the following values:OguryTopRight
OguryTopLeft
OguryBottomLeft
OguryBottomRight
Thumbnail Ad remains on screen while the user is navigating between
ViewController
of your application.By default, a Thumbnail Ad is displayed in an
ViewController
only if this bundle identifier are the main bundle of application.You can override these default settings using whitelists and blacklists.
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:Swift
Objective-C
self.thumbnailAd.setWhitelistBundleIdentifiers(["com.example.bundle", "com.example.bundle2"])
[self.thumbnailAd setWhitelistBundleIdentifiers:@[@"com.example.bundle", @"com.example.bundle2"]];
You can prevent Thumbnail Ads from being displayed on a given
ViewController
by using the setBlacklistViewControllers
method:Swift
Objective-C
self.thumbnailAd.setBlacklistViewControllers([NSStringFromClass(TermsAndConditionsViewController.classForCoder()), NSStringFromClass(SettingsViewController.classForCoder())])
[self.thumbnailAd setBlacklistViewControllers:@[NSStringFromClass([TermsAndConditionsViewController class]), NSStringFromClass([SettingsViewController class])]];
When the user navigates to a
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.The Ogury SDK provides
OguryThumbnailAdDelegate
to listen to the lifecycle of a Thumbnail Ad instance. To register a
OguryThumbnailAdDelegate
, add the following code just after instantiating the OguryThumbnailAdForGoogleMobileAds
:Swift
Objective-C
self.thumbnailAd.delegate = self
self.thumbnailAd.delegate = self;
The
OguryThumbnailAdDelegate
exposes the following methods:Methods | Definition |
---|---|
didLoadOguryThumbnailAd | The SDK is ready to display the ad provided by the ad server. |
didDisplayOguryThumbnailAd | The ad has been displayed on the screen. |
didClickOguryThumbnailAd | The as has been clicked by the user. |
didCloseOguryThumbnailAd | The ad has been closed by the user. |
didFailOguryThumbnailAdWithError | The ad failed to load or display. The error parameter contains the reason of the failure. All error codes are detailed in the section below. |
When an ad fails to load or to be displayed, the SDK will call the
didFailOguryTAdWithError
callback with one of error code defined in OguryAdsError
:Name | Value | Definition |
---|---|---|
OguryCoreErrorTypeNoInternetConnection | 0 | No Internet connection The device has no Internet connection. Try again once the device is connected to the Internet. |
OguryAdsAdDisabledError | 2001 | Ad disabled Ad serving has been disabled for this placement/application. |
OguryAdsProfigNotSyncedError | 2002 | Profig not synchronized An internal SDK error has occurred. |
OguryAdsAdExpiredError | 2003 | Ad expired The loaded ad is expired. You must call the show method within 4 hours after the load . |
OguryAdsSdkInitNotCalledError | 2004 | SDK init not called The Ogury.start() method has not been called before a call to the load or show methods. |
OguryAdsAnotherAdAlreadyDisplayedError | 2005 | Another ad already displayed Another ad is already displayed on the screen. |
OguryAdsAssetKeyNotValidError | 2006 | SDK init failed An error occurred during the initialization of the SDK. |
OguryAdsNotAvailableError | 2008 | Ad not available The server returns no ads. |
OguryAdsCantShowAdsInPresentingViewControllerError | 2010 | A view controller is already being presented Only one view controller may be presented at a time. |
OguryAdsUnknownError | 2011 | Unknown error An unknown error occurred. |
Last modified 10mo ago