-
Notifications
You must be signed in to change notification settings - Fork 6
Header Bidding
Adform Advertising SDK allows you to use header bidding.
-
Create ad request in this way:
BidRequest bidRequest = new BidRequest.Builder() .setPlacementType(AdformEnum.PlacementType.INLINE) .setMasterTag(142493) .setAdSize(new AdSize(320, 50)) .build();
It is required to set master tag, other parameters are optional.
-
You need to initialize ad loader using
Context
andBidRequest
as parameters:BidLoader bidLoader = new BidLoader(this, bidRequest);
-
Set loading listener in order to receive events about ad loading:
bidLoader.setListener(new AdLoadListener() { @Override public void onSuccess(BidResponse bidResponse) { //do something with result } @Override public void onFail(String errorMessage) { //do something with error } });
You would need to implement handling of response for yourself.
-
Finally, you could start loading:
bidLoader.requestBids();
There are additional functions which helps during the header bidder setup. These functions are created for different means and provide an easy way of setting pricing and pass custom data to the ad server that then is returned to the ad code – i.e. ad ID that should be rendered.
To set actual winning price from the header bidder auction for a placement you have to use price
property of the ad view. This functionality is available for all ad types. Example bellow illustrates how to do it.
adInline.setPrice(8.5);
To set custom key value data (easy way of passing some data back to the ad that needs to be rendered) to a placement you have to use setCustomData()
method of the ad view. Custom data functionality is available for all ad types. Example bellow illustrates how to do it.
HashMap<String, String> customData = new HashMap<>();
customData.put("gender", "male");
adInline.setCustomData(customData);
In order to load Adform banners with Google DFP SDK using Adform Header Bidding SDK you need to follow these steps:
- Configure a creative for header bidding on DFP interface. Please visit our Publisher help center for more information.
- Import Adform Header Bidding SDK and Google DFP SDK to your project. For more information on Adform Header Bidding SDK integration take a look at the top of the document and more information about Google DFP SDK integration can be found here.
- Make a bid request using Adform Header Bidding SDK.
BidRequest bidRequest = new BidRequest.Builder()
.setPlacementType(AdformEnum.PlacementType.INLINE)
.setMasterTag(masterTag)
.setAdSize(new AdSize(width, height))
.build();
mBidLoader = new BidLoader(this, bidRequest);
mBidLoader.setListener(new BidLoadListener() {
@Override
public void onSuccess(BidResponse bidResponse) {
Log.d(TAG, "onSuccess" + bidResponse.toString());
showDfpBanner(bidResponse);
}
@Override
public void onFail(String errorMessage) {
Log.d(TAG, "onFail" + errorMessage);
showDfpBanner(null);
}
});
mBidLoader.requestBids();
- Pass bid price, ad unit and bidder name to DFP ad request.
PublisherAdRequest adRequest;
PublisherAdRequest.Builder builder = new PublisherAdRequest.Builder();
if(bidResponse != null){
DecimalFormat decim = new DecimalFormat("0.00");
String price = decim.format(bidResponse.getCpm());
adRequest = builder
.addCustomTargeting("hb_bidder", "adform")
.addCustomTargeting("hb_adid", bidResponse.getAdUnitScriptEncoded().replaceAll("=", "-"))
.addCustomTargeting("hb_pb", price).build();
} else {
adRequest = builder.build();
}
- Load the ad.
mPublisherAdView.loadAd(adRequest);
Basic integrations
- Integrating Inline Ad
- Integrating Full Screen Overlay Ad
- Integrating Interstitial Ad
- Integrating Adhesion Ad
- Video Ad Integration
Advanced integrations
- Advanced integration of Inline Ad
- Advanced integration of Full Screen Overlay Ad
- Advanced integration of Interstitial Ad
- Advanced integration of Adhesion Ad
- Advanced integration of AdInline ListView
- Advanced integration of AdInline RecyclerView
- Instream video ads integration
Other
- Adding Custom Values
- Adding Keywords
- Adding Key Value Pairs
- Adding Search Words
- Location
- Security
- Ad Tags
- Header Bidding
- Changing ADX domain
- Specifying banner loading behaviour
- GDPR
- Logs
Mediation adapters
Plugins