Configuring Clickthrough

This guide is intended for iOS publishers interested in getting more control over clickthrough in their IMA SDK implementation. "Clickthrough" refers to the process of a user clicking on an ad and getting to the landing page for that ad. In this guide, we'll show you how to configure where that landing page opens, and how to listen for events related to your user visiting that page.

Prerequisites

  • iOS application with the IMA SDK implemented.

Helpful primers

If you still need to implement the IMA SDK in your app, check out our Get Started guide.

Configuring clickthrough

Changing the web opener

The IMA SDK offers two options for opening ad landing pages—via an in-app browser, or via Safari. By default, the SDK will open pages using Safari. To update the SDK to use an in-app browser, you'll need to use IMAAdsRenderingSettings:
- (void)createAdsRenderingSettings {
  self.adsRenderingSettings = [[IMAAdsRenderingSettings alloc] init];
  self.adsRenderingSettings.webOpenerDelegate = self;
  self.adsRenderingSettings.webOpenerPresentingController = self;
}
Once you've configured the IMAAdsRenderingSettings instance, you can pass it to the IMAAdsManager initialization method:
[self.adsManager initializeWithAdsRenderingSettings:adsRenderingSettings];

Listening for clickthrough-related events

The IMA SDK provides the IMAWebOpenerDelegate to communicate when the user is about to see or has just closed a clickthrough page. To use this delegate, add it to your delegate list in the header, and implement its methods. In the header:
@interface ViewController : UIViewController<IMAWebOpenerDelegate>
And in the implementation:
- (void)webOpenerWillOpenExternalBrowser:(NSObject *)webOpener {
  NSLog(@"External browser will open.");
}

- (void)webOpenerWillOpenInAppBrowser:(NSObject *)webOpener {
  NSLog(@"In-app browser will open");
}

- (void)webOpenerDidOpenInAppBrowser:(NSObject *)webOpener {
  NSLog(@"In-app browser did open");
}

- (void)webOpenerWillCloseInAppBrowser:(NSObject *)webOpener {
  NSLog(@"In-app browser will close");
}

- (void)webOpenerDidCloseInAppBrowser:(NSObject *)webOpener {
  NSLog(@"In-app browser did close");
}