To use PubMatic as a client-side demand source, publishers can use third-party mediation support in the DFP SDK to integrate PubMatic iOS SDK for Banner ads. PubMatic provides a client side mediation adapter to integrate the PubMatic SDK with the DFP SDK. Using the guidelines provided below, publishers can easily integrate a PubMatic adapter and DFP SDK into a mobile app with minimal code changes. The following diagram illustrates the call flow of mediation ad serving.
Mediation Ad Serving Call Flow
- DFP SDK, which is integrated into application, requests ad from DFP ad server.
- DFP responds back with mediation response containing Custom Event Class names (for example,
PMCustomEventBanner) and server parameter containing PubMatic’s ad tag information. We recommend you specify this parameter as
- DFP SDK initializes the PubMatic adapter using the class name when it receives the mediation response, then passes the server parameter.
- PubMatic adapter initializes PubMatic SDK with the details received (that is,
adId), from the server parameter.
- PubMatic SDK then makes a call to PubMatic ad server requesting an ad.
- PubMatic ad server responds with an ad.
- PubMatic SDK delegates control to the adapter.
- The adapter then hands over rendered ad to DFP SDK and informs the result with standard callbacks.
Configuring the PubMatic Network on DFP Portal
Use the following steps to configure the Custom Event on DFP portal:
- Log in to the DFP account.
- Navigate to the Delivery > Yield groups tab and create a yield group.
- Select the Ad format > Banner and Environment > Mobile app you wish to target with this yield group.
- Select inventory Sizes and add Targeting criteria, if any:
- Choose Add another yield partner to add PubMatic as a third-party mediation partner. Select Yield partner as PubMatic, if already defined, otherwise, select Create a new yield partner and add PubMatic as a new yield partner.
- Select Integration type > Custom event mediation then select Operating system > iOS. You can also enter a Label if needed.
- Add the name of your custom event in Class Name (for example,
PMCustomEventBanner), then specify PubMatic’s tag in the Parameter field in
<pubId_siteId_adId>format. You can also specify Default CPM if needed.
- Choose SAVE AND ACTIVATE
PubMatic Banner Adapter for DFP SDK
Integrate the DFP SDK (Google-Mobile-Ads-SDK) in your project. This document refers to DFP SDK version 7.28.0.
Monetize your app with ad networks that mediation does not directly support by using DFP Custom Events. Implement a custom event using the
- Create a class that implements
GADCustomEventBannerin your app; for example,
PMCustomEventBanner(here "PM" stands for PubMatic).
-requestBannerAd:parameter:label:request:method and implement code that requests an ad from PubMatic. See the PubMatic SDK Developer Guide, to create an instance of
PMBannerAdViewview and sending ad requests. Your code may be similar to the following:
Your code must notify DFP when your ad successfully loads by calling the
- customEventBanner:didReceiveAd:method on the custom event object’s delegate (accessible via the delegate property), similar to the following:
- Your code must also notify the delegate if your ad fails to load by calling the
Optional steps include:
Notify the delegate of user interaction events using corresponding delegate methods:
Notify the delegate using the
- customEventBannerWillLeaveApplication:method if the user leaves the app from a banner ad.
-deallocmethod if your custom event requires any sort of cleanup, similar to the sample code below:
Once you've completed these steps, the DFP SDK can automatically instantiate your class when your app runs. You do not need to explicitly instantiate any of these classes in your app's code.