Android Mediation

Android Google Ad Manager Adapter

Android Google Ad Manager (GAM) Mediation Adapter supports all display.io ad units.

Google Ad Manager/ display.io ad units mapping:

display.io       GAM
 mceclip29.png          Interscroller    Banner                format-banner.svg
 mceclip33.png Headline Video    Banner                format-banner.svg
 mceclip34.png Interstitial    Interstitial                format-interstitial.svg
 mceclip31.png Infeed    Banner                format-banner.svg
 mceclip32.png Medium Rectangle    Banner                format-banner.svg
 mceclip30.png Banner    Banner                format-banner.svg

 

To set it up:

1. Add the adapter to your project:

Edit your project’s build.gradle file in order to declare our maven repository:

 repositories {
    google()
    jcenter()
    maven { url "http://maven.display.io/" }
 }

Add the following dependencies to your app-module’s build.gradle file:

implementation ‘com.brandio.ads:sdk:4.5.2.1’
implementation ‘com.brandio.ads:google-ads-adapter:4.5.2.2'

Follow guide to initialize DisplayIO SDK.

 

2. Create a new Yield Group (Banner) and add Third-Party Yield Partner (DisplayIO) to the Yield Group. If you require more instruction on this please consult the link below: https://support.google.com/admanager/answer/7390828

 

3. Define a Custom Banner Event using the following guide: https://developers.google.com/ad-manager/mobile-ads-sdk/android/custom-events#banner_custom_event

Update to the following settings:

dfp_custom_event_banner.jpg

 

For each ad unit use Class Name:

  • Interstitial ad unit: com.brandio.ads.adapters.googleads.InterstitialAdapter
  • Infeed ad unit: com.brandio.ads.adapters.googleads.InfeedAdapter
  • Interscroller ad unit: com.brandio.ads.adapters.googleads.InterscrollerAdapter
  • Banner ad unit: com.brandio.ads.adapters.googleads.BannerAdapter 
  • Medium Rectangle ad unit: com.brandio.ads.adapters.googleads.MediumRectangleAdapter
  • OutStreamVideo ad unit: com.brandio.ads.adapters.googleads.OutStreamVideoAdapter 

and Parameter <PLACEMENT_ID>, where PLACEMENT_ID is your placement ID on display.io platform (display.io Publisher Portal).

 

4. Create a new ad unit and specify the newly created network as a source. Disable auto-refreshing for banner.

 

5. Make sure that DisplayIO network has a higher priority than any other sources (usually Google adds its own source by default).

 

6. Use Banner or Interstitial tutorials to get ads from Google Ad Manager.

 

7. Infeed can be added in RecyclerView by passing it as adapter’s constructor argument:

RecyclerViewAdapter( ... , @NonNull AdView adView) {

...

    this.adView = adView;

}

and can be shown in particular position with help of RecyclerView.ViewHolder subclass in RecyclerView.Adapter.onCreateViewHolder method:

...

static class AdHolder extends RecyclerView.ViewHolder {
   AdHolder(View itemView) {
       super(itemView);
   }
}

...

@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull final
ViewGroup parent, int viewType) {

...

   return new AdHolder(adView);
}

...

9. Interscroller could be added in RecyclerView like Banner but it require additional step: Set up your placement with field to store reference to parent (RecyclerView object) Make sure you call it after DisplayIO SDK has beed initialized:

try {
    InterscrollerPlacement placement = (InterscrollerPlacement) Controller
                                       .getInstance().getPlacement(IS_PLACEMENT_ID);
    placement.setParentRecyclerView(recyclerView);
} catch (DioSdkException e) {
    e.printStackTrace();
}

 

Important:
Disabling auto impression tracking for Interscroller is strongly recommended to avoid discrepancies between Ad Manager and DisplayIO metrics.

PublisherAdRequest adRequest = new PublisherAdRequest.Builder()
    .setManualImpressionsEnabled(true)
    .build();

In order to count the impression you should listen onAdOpened() on your PublisherAdView:

@Override
public void onAdOpened() {
   mPublisherAdView.recordManualImpression();
}

 

Still have Questions?

Contact Us