In-App Header Bidding

Appnext SDK In-App Header Bidding

What is Header Bidding?

Header bidding, also known as advance bidding or pre-bidding, is a progressive programmatic technique wherein publishers offer inventory to multiple ad exchanges simultaneously before making calls to their ad servers. By letting multiple demand sources bid on the same inventory at the same time, publishers increase their yield and grow their revenues.

Appnext in-app solution for header bidding

Appnext solution enables the publisher to get the predicted ECPM value of the ad unit that is about to load. In this way the publisher can programmatically decide whether to load the ad and show it or not.

The getECPM function

After creating the ad unit as described in step 2 above, it is possible to get the predicted ECPM value by executing the geteCPM function.

Upon success, the function will return ecpm object within the OnECPMLoaded callback. The ecpm object will include three getters:

  • getEcpm - Returns the predicted ECPM value of the banner that is about to be loaded (float type)
  • getPpr - Returns the predicted price per request value (ECPM value / 1000) (float type)
  • getBanner - Returns the banner ID of the banner that is about to load (String type)

You can use the error function in case the getECPM function fails (unlikely). The returned error strings are the same as the AdsError callback.

Examples

Fullscreen ad unit example

fullscreen_ad.getECPM(new OnECPMLoaded() {
   @Override
   public void ecpm(ECPM ecpm) {
      Log.v("ecpm", "ecpm: " + ecpm.getEcpm() + ", ppr: " + ecpm.getPpr() + ", banner ID: " + ecpm.getBanner());
      fullscreen_ad.loadAd();
   }
   
   @Override
   public void error(String error) {
      Log.v("ecpm", "error: " + error);
   }
});
fullscreen_ad.getECPM(new OnECPMLoaded() {
   @Override
   public void ecpm(ECPM ecpm) {
      float appnextEcpm = ecpm.getEcpm();
      if (appnextEcpm > 0.05) {
           fullscreen_ad.loadAd();
      }
      else {
           // handle this case
      }
   }
});

Interstitial ad unit example

interstitial_Ad.getECPM(new OnECPMLoaded() {
   @Override
   public void ecpm(ECPM ecpm) {
      Log.v("ecpm", "ecpm: " + ecpm.getEcpm() + ", ppr: " + ecpm.getPpr() + ", banner ID: " + ecpm.getBanner());
      interstitial_Ad.loadAd();
   }
   
   @Override
   public void error(String error) {
      Log.v("ecpm", "error: " + error);
   }
});
interstitial_Ad.getECPM(new OnECPMLoaded() {
   @Override
   public void ecpm(ECPM ecpm) {
      float appnextEcpm = ecpm.getEcpm();
      if (appnextEcpm > 0.05) {
           interstitial_Ad.loadAd();
      }
      else {
           // handle this case
      }
   }
});

Banner ad unit example

banner.getECPM(new BannerAdRequest(), new OnECPMLoaded() {
   @Override
   public void ecpm(ECPM ecpm) {
       Log.v("ecpm", "ecpm: " + ecpm.getEcpm() + ", ppr: " + ecpm.getPpr() + ", banner ID: " + ecpm.getBanner());
       BannerAdRequest banner_request = new BannerAdRequest();
       banner.loadAd(banner_request);
   }

   @Override
   public void error(String s) {
       Log.v("ecpm", "error: " + s);
   }
});
banner.getECPM(new BannerAdRequest(), new OnECPMLoaded() {
   @Override
   public void ecpm(ECPM ecpm) {
       float appnextEcpm = ecpm.getEcpm();
       if (appnextEcpm > 0.05) {
         	BannerAdRequest banner_request = new BannerAdRequest();
          banner.loadAd(banner_request);
       }
       else {
           // handle this case
       }
   }

   @Override
   public void error(String s) {
			// handle this case
   }
});

New Native Ads ad unit example

The predicted ECPM value is now returned within the ad metadata, within the onAdLoaded callback. The value can be fetched in two forms::

  • ECPM - by using the getECPMValue() function. This function returns the predicted ECPM value of the ad that is about to be showed in the current ads list array (float type)
  • PPR - by using the getPPR() function. This function returns the PPR value (price per request which is ECPM value / 1000) of the ad that is about to be showed in the current ads list array (float type)

Error handling is done by using the adError callback as described above

// New Native Ads
...
NativeAd nativeAd = new NativeAd(this, "ADD_HERE_YOUR_PLACEMENT_ID");
		nativeAd.setAdListener(new NativeAdListener(){
			@Override
			public void onAdLoaded(NativeAd nativeAd) {
				super.onAdLoaded(nativeAd);
            float example_ad_ecpm = nativeAd.getECPM();
            float example_ad_ppr = nativeAd.getPPR();
            if (example_ad_ecpm > 0.05) {
                //Built the native ad UI by using the 
                //ad metadata get functions
            }
            else {
               //handle this case
            }
        }
        });
		nativeAd.loadAd(new NativeAdRequest());
...
      

// Native Ads (Deprecated)
...
exampleAppnextAPI = new AppnextAPI(this, "YOUR_PLACEMENTID");
    exampleAppnextAPI.setAdListener(new AppnextAPI.AppnextAdListener() {
        @Override
        public void onAdsLoaded(ArrayList arrayList) {
            example_ad = arrayList.get(0);
            float example_ad_ecpm = example_ad.getECPM();
            float example_ad_ppr = example_ad.getPPR();
            if (example_ad_ecpm > 0.05) {
                //Built the native ad UI by using the 
                //ad metadata get functions
            }
            else {
               //handle this case
            }
        }
            
        @Override
        public void onError(String s) {
             //error handling goes here
        }
        });
exampleAppnextAPI.loadAds(new AppnextAdRequest().setCount(1));
...

Important notes

  • We suggest to initialize the Appnext SDK and use the getECPM function before calling any other SDK or mediation to maximize your yield
  • The prediction ECPM value is an estimated value and not a guaranteed value
  • The predicted ECPM value should be used earlier as possible once it was retrieved
  • The adLoaded in the OnAdLoaded now returns the Banner ID. You can compare it to the Banner ID received in the ecpm object
  • This is a new and innovative feature! We recommend to contact your account manager or integration specialist before using it