Header Bidding

Mintegral SDK supports bidding in mobile apps . Mobile app bidding integrations can be from the mobile client to our server . This overview will cover the general concepts of app bidding and provides instructions on how to integrate the App Head-Bidding in mobile with Mintegral SDK. Mintegral SDK provides 6 different Ads formats which are Banner, Native, Native Video, Rewarded Video, Interstitial Video and Splash and which can be supported for App Head-Bidding.

1. Introduction

1.1 What Is App Head-Bidding

App Head-Bidding is a way for publishers to establish an impartial and open auction over their ad inventory by offering every ad opportunity to multiple demand sources in real time. Every demand source has the opportunity to compete and win every impression, when the value is the highest.

1.2 Why App Bidding

  • A real-time auction is an opportunity to optimize for every ad request.

  • Provides visibility into the true value of your ad inventory.

  • Easy to maintain and requires less ad operations resources.

2. Integration Summary

Mintegral provides two types of header bidding, including client-side bidding and server-side bidding.

2.1 Client-Side Header Bidding

In this process, developers can request to start bidding through the Mintegral SDK and select the highest bid as the winner, all taking place within the app.

Key Steps:

  • Before the ad impression is available, the app calls for Mintegral SDK's bid request API, and Mintegral SDK will communicate with the server to retrieve bid responses.

  • The app will receive the prices and bidtokens(the token to load the ad) through the returned responses.

  • The app will select a winner through the auction price logic.

  • .If Mintegral wins the bid, the developer can call for the SDK's loadfrombid API to load the ad.

2.2 Server-Side Header Bidding

In this process, developers can request for bidding within its own server (or through a 3rd party mediation platform’s server) and can select a winner within the server.

Key Steps:

  • Before the ad impression is available, the app calls for Mintegral SDK's BidManager.getBuyerUid API to get the buyer ID.(optional)

  • Publisher's app can report the buyeruid to its own server so that it can be used when making a request to Mintegral's server.(optional)

  • The developer's server needs to send bidding requests that abide to the OpenRTB protocol (Reference) to Mintegral's server.

  • After Mintegral ad platform's server responds to the bidding request and begins bidding, the developer can order the bids and select a winner within its own server. Simultaneously, they will send out respective parameters including Bidid.

  • The developer's server notifies the app that Mintegral has won the bid, then the app calls for Mintegral SDK's loadfrombid API.

3.SDK Integration Details

The ad formats supported by Mintegral SDK's header bidding includes native video, rewarded video and interstitial video ads.

Before integrating the In-app Header Bidding logic, make sure you have read the MTGSDK's Android integration documentation (or iOS integration documentation) or have integrated MTGSDK into your project.

3.1 Android

3.1.1 Getting the bidding SDK module

Unzip Mintegral SDK. Drag and drop both mbbid.aar(jar) and same.aar(jar) into your project. Or use Gradle integration(Please ensure that the version numbers of the Bid SDK and your Mtg SDK are the same).

3.1.2 Initialization

1.Put the initiating codes into Application through the respective App ID and App Key. See below example code for reference. It is recommended to use the API in the main thread, And Initialize The SDK as soon as your app starts.Ensure that the SDK is initialized each time the application is restarted.Note that the AppId, AppKey, and the unitId of the load ad must be filled,cannot be set null.

Sample code:

3.1.3 Sending the bid request

Note:If you are using server to server bidding method, you can ignore this step.

In your Activity or Fragment, create BidManager object like this:

After the BidManager object is created, we can send the request by calling the bid method, which takes a BidListenner object to handle the bid response.Note that before calling the bid method, be sure to the SDK initialization success.

Sample code:

3.1.4 Running the auction

Note:This section pertains to processing bid response from client-side bidding, if you are using server to server bidding, you must process the bid response within the server.

In this part, we take the bid response from MintegralSDK and compare it with CPM prices from other buyers, and decide whether the MintegralSDK wins and loads the ad, or it loses. When you determine with the result of the auction, call the methods sendWinNotice(Context context) or sendLossNotice(Context context,BidLossCode bidLossCode) to notify MTG about the result.

Note that the auction logic is implemented by the app itself. It should be simply comparing bid prices and choosing the highest bidder as the auction winner. Here is an example of how to use the returned bidResponse and run an auction in an Android app.

3.1.5 Loading the ad with bid response payload

  • Banner

When the Mintegral SDK bid wins an auction, the next step is to use the MBBannerView with loadFromBid(String bidToken) method to retrieve an ad and then show it. Similar to normal ad loading, app side bidding integration you will need to create the ad object The difference is that instead of calling load() method, you call the loadFromBid(String bidToken) with the bidToken from the BidResponsed, which you can get from bidResponsed.getBidToken(). The callback methods of the listener work the same as normal ad object listeners.

Sample Code:

  • Native(NativeVideo)

When the Mintegral SDK bid wins an auction, the next step is to use the MBBidNativeHandler with bidLoad(String bidToken) method to retrieve an ad and then show it. Similar to normal ad loading, app side bidding integration you will need to create the ad object The difference is that instead of calling load() method, you call the bidLoad(String bidToken) with the bidToken from the BidResponsed, which you can get from bidResponsed.getBidToken(). The callback methods of the listener work the same as normal ad object listeners.

Sample Code:

  • RewardVideo

When the Mintegral SDK bid wins an auction, the next step is to use the MBRewardVideoHandler with load(String bidToken) method to retrieve an ad and then show it. Similar to normal ad loading, app side bidding integration you will need to create the ad object The difference is that instead of calling load() method, you call the loadFromBid(String bidToken) with the bidToken from the BidResponsed, which you can get from bidResponsed.getBidToken(). The callback methods of the listener work the same as normal ad object listeners.

Sample code:

  • IntestitialVideo

When the Mintegral SDK bid wins an auction, the next step is to use the MBBidInterstitialVideoHandler with load(String bidToken) method to retrieve an ad and then show it. Similar to normal ad loading, app side bidding integration you will need to create the ad object The difference is that instead of calling load() method, you call the loadFromBid(String bidToken) with the bidToken from the BidResponsed, which you can get from bidResponsed.getBidToken(). The callback methods of the listener work the same as normal ad object listeners.

Sample code:

  • Splash

When the Mintegral SDK bid wins an auction, the next step is to use the MBSplashHandler with preLoadByToken(String token) or loadAndShowByToken(String token, ViewGroup container) method to retrieve an ad and then show it. Similar to normal ad loading, app side bidding integration you will need to create the ad object. The difference is that instead of calling load() method, you call the preLoadByToken(String token) or loadAndShowByToken(String token, ViewGroup container)with the bidToken from the BidResponsed, which you can get from bidResponsed.getBidToken(). The callback methods of the listener work the same as normal ad object listeners.

Sample code:

3.2.6 Obtain buyerUID(optional)

Note: This step is only required for developers using the server to server bidding architecture. If you are using the client to server bidding architecture, you do not need to obtain the buyerUID. By obtaining and using the buyerUID, Mintegral’s algorithms will be able to further optimize your ads’ performances. However, this step is not mandatory

Call for static method BidManager.getBuyerUid(Context context) to obtain the unique buyerUID and transfer the buyerUID to your own server. This parameter will be used in the server-side bid requestsObject:User and it is recommended that you obtain the buyerUID each time you initialize your app or each time before you request for bids.

3.2 iOS

3.2.1 Getting the bidding SDK module

Unzip the Mintegral SDK. Drag and drop both MTGSDK.framework and MTGBidding.framework into your project in XCode.

3.2.2 Initialization

Initialize The SDK as soon as your app starts.Call for the MTGSDK initialization method in AppDelegate through the API below and import it to the App ID and App Key from Mintegral dashboard. When initializing, MTGSDK will retrieve configuration information from the server. It is recommended to use the API in the main thread.Note that the AppId, AppKey, and the unitId of the load ad must be filled,cannot be set null.

Sample Code:

3.2.3 Sending the bid request

Note: If you are using server to server bidding method, you can ignore this step.

In your iOS code, create a bid request like this:(Note that before calling the method, be sure to the SDK initialization success.)

3.2.4 Running the auction

Note :This section pertains to processing bid response from client-side bidding, if you are using server to server bidding, you must process the bid response within the server.

In this part, we take the bid response from Mintegral SDK and compare it with CPM prices from other buyers, and decide whether the Mintegral SDK wins and load the ad, or it loses. When you are determined with the result of the auction, call the methods notifyWin or notifyLoss to notify Facebook about the result. Here is an example of how to use the returned bidResponse and run an auction in an ios app.

3.2.5 Loading the ad with bid response payload

  • Banner

When the Mintegral SDK bid wins an auction, the next step is to use the bid response with loadBannerAdWithBidToken method to retrieve an ad and then show it. Similar to normal ad loading, in client side bidding integration you will need to create the ad object and specify the corresponding ad listener object to handle the callback methods. The difference is that instead of calling loadAd method, you call the loadBannerAdWithBidToken with the payload from the bid response, which you can get from bidResponse.bidToken. The callback methods of the listener works the same as normal ad object listeners.

Sample Code:

  • Native(NativeVideo)

When the Mintegral SDK bid wins an auction, the next step is to use the bid response with loadWithBidToken method to retrieve an ad and then show it. Similar to normal ad loading, in client side bidding integration you will need to create the ad object and specify the corresponding ad listener object to handle the callback methods. The difference is that instead of calling loadAd method, you call the loadWithBidToken with the payload from the bid response, which you can get from bidResponse.bidToken. The callback methods of the listener works the same as normal ad object listeners.

Sample Code:

  • RewardVideo

When the Mintegral SDK bid wins an auction, the next step is to use the bid response with loadAdWithBidPayload method to retrieve an ad and then show it. Similar to normal ad loading, in client side bidding integration you will need to create the ad object and specify the corresponding ad listener object to handle the callback methods. The difference is that instead of calling loadVideo method, you call the loadVideoWithBidToken with the payload from the bid response, which you can get from bidResponse.bidToken. The callback methods of the listener works the same as normal ad object listeners.

Sample code:

  • IntestitialVideo

When the Mintegral SDK bid wins an auction, the next step is to use the bid response with loadAdWithBidPayload method to retrieve an ad and then show it. Similar to normal ad loading, in client side bidding integration you will need to create the ad object and specify the corresponding ad listener object to handle the callback methods. The difference is that instead of calling loadAd method, you call the loadAdWithBidToken with the payload from the bid response, which you can get from bidResponse.bidToken. The callback methods of the listener works the same as normal ad object listeners.

Sample code:

  • Splash

When the Mintegral SDK bid wins an auction, the next step is to use the bid response to retrieve an ad and then show it. Similar to normal ad loading, in client side bidding integration you will need to create the ad object and specify the corresponding ad listener object to handle the callback methods. The difference is that instead of calling preload or loadAndShowXXX method, you call the preloadWithBidToken or loadAndShowXXXbidToken with the payload from the bid response, which you can get from bidResponse.bidToken. The callback methods of the listener works the same as normal ad object listeners.

Sample code:

3.2.6 Obtain buyerUID(optional)

Note: This step is only required for developers using the server to server bidding architecture. If you are using the client to server bidding architecture, you do not need to obtain the buyerUID. By obtaining and using the buyerUID, Mintegral’s algorithms will be able to further optimize your ads’ performances. However, this step is not mandatory.

Call for static method [MTGBiddingSDK buyerUid] to obtain the unique buyerUID and transfer the buyerUID to your own server. This parameter will be used in the server-side bid requestsObject:User and it is recommended that you obtain the buyerUID each time you initialize your app or each time before you request for bids.

4.Server-Side OpenRTB Protocol

The developer needs to send bidding requests that abide to the OpenRTB 2.5 protocol if they want to bid directly with Mintegral’s server.

4.1 Request Parameters

Bid requests and bid responses will be custom-adjusted according to the OpenRTB 2.5 protocol. Using json format and need add openrtb:2.5 in Http Header. You can use -H "openrtb:2.5" if you use Curl test.

Http request method: POST

Request interface addresshttp://hb.rayjump.com/bid

4.1.1 Object:BidRequest

Attribute

Type

Description

id

string; required

Unique ID of the bid request, provided by the exchange.

imp

object array; required

Imp object, represents one impression, MTG only allows one imp object in each request.

app

object; required

Details about the developer's app; refer to APP object.

device

object;required

Details about the user's device; refer to device object.

user

object;required

Details about the user of the device; refer to user object.

at

integer; optional;default 1

Auction type, where 1 = First Price, 2 = Second Price Plus.

4.1.2 Object:Imp

Attribute

Type

Description

id

string;required

A unique identifier for this impression within the context of the bid request, starts with 1 and increments.

displaymanager

string;optional

Name of ad mediation partner.

placement_id

string;optional

The ID of your ad placement. You can find 'Placement ID' on your Mintegral account dashboard, under the tab "Placements & Units".

displaymanagerver

string;required

Name of integrated MTG-SDK version.

tagid

string;required

MTG ad unit ID.

bidfloor

float;optional default 0

Minimum bid for this impression expressed in CPM.

bidfloorcur

string;optional;default "USD"

Currency of the bid, default is USD.

4.1.2.1 Object:Imp.banner

Attribute

Type

Description

w

string;required

Request the width of the banner ad

h

string;required

Request the height of the banner ad

4.1.2.2 BidRequest.imp.ext.skadn

Attribute

Type

Description

Example

version

String;optional

Version of SKAdNetwork supported. Always "2.0" or higher. Dependent on both the OS version and the SDK version.

"version":"2.0"

sourceapp

String;optional

ID of publisher app in Apple’s App Store. Should match BidRequest.app.bundle

"sourceapp":"880047117"

skadnetids

String Array;optional

A subset of SKAdNetworkIdentifier entries in the publisher app’s info.plist that are relevant to the DSP.

["SKAdNetwork1.skadnetwork"," SKAdNetwork2.skadnetwork"]

4.1.3 Object:App

Attribute

Type

Description

id

string;required

MTG app ID.

ver

string;optional

Application version.

ext

object;optional

Self-defined object, includes orientation field.

4.1.3.1 Object:Orientation Ext

Attribute

Type

Description

orientation

int;required

Application's orientation; where 1= portrait and 2 = landscape and 3 = unknown.

4.1.4 Object:Device

Attribute

Type

Description

ua

string;required

Application user agent string.

ip

string;required

IPv4 address.must choose between ip and ipv6

ipv6

string;required

IPv6 address. must choose between ip and ipv6

devicetype

integer;required

Type of device where 1 = phone and 2 = tablet.

make

string;required

Device make or brand

model

string;required

Device model.

os

string;required

Device operating system.

osv

string;required

Device operating system version.

h

integer;required

Physical height of the screen in pixels.

w

integer;required

Physical width of the screen in pixels.

language

string;required

Browser language using ISO-639-1-alpha-2.

mccmnc

string;optional

Mobile carrier, string formed by combining MCC and MNC.

connectiontype

integer;required

Network connection type.

ifa

string;required

iOS-idfa, android-gaid

didsha1

string;optional

IMEI sha1

didmd5

string;optional

IMEI md5

Dpidsha1

string;optional

android_id sha1

dpidmd5

string;optional

android_id md5

4.1.5 Object:User

Attribute

Type

Description

buyeruid

string;required

Buyer-specific ID for the user as mapped by MTG.

4.2 Response Data返回数据

Below are examples of the various parameters of the returned data's data structure.

4.2.1 Object:BidResponse

Attribute

Type

Description

id

string;required

Returned bid request ID.

seatid

object array

Refer to seat ID object.

bidid

string;optional

MTG generated token ID used to load ad.

cur

string;default "USD"

Bid currency, default is USD.

nbr

integer;optional

Reason for not bidding.

4.2.1.1 Object:SeatBid

Attribute

Type

Description

bid

object array;required

Refer to bid object.

4.2.1.1.1 Object:Bid

Attribute

Type

Description

Description

id

string;required

bid id

Unique bid ID.

impid

string;required

请求时的imp.id

Returned bidrequest.imp.id, ID of the Imp object in the related bid request.

price

float;required

bid的出价

Bid price expressed as CPM

nurl

string;required

win notice url

Win notice URL called by MTG if the bid wins.

lurl

string;required

loss notice url

Loss notice URL called by MTG if the bid loss.

4.2.1.1.1.1 Object:BidResponse.seatbid.bid.ext.skadn

Attribute

Type

Description

Example

version

String;optional

Version of SKAdNetwork desired. Must be 2.0 or above.

"version":"2.0"

network

String;optional

Ad network identifier used in signature. Should match one of the items in the skadnetids array in the request

"network":"dsp1.skadnetwork"

campaign

String;optional

Campaign ID compatible with Apple’s spec. As of 2.0, should be an integer between 1 and 100, expressed as a string

"campaign":"45"

itunesitem

String;optional

ID of advertiser’s app in Apple’s app store. Should match BidResponse.bid.bundle

"itunesitem":"880047117

nonce

String;optional

An id unique to each ad response

"nonce": "beeeb65e-b3de-02420004"

sourceapp

String;optional

ID of publisher’s app in Apple’s app store. Should match BidRequest.imp.ext.skad.sourceapp

"sourceapp":"123456789"

timestamp

String;optional

UNIX time in millis string used at the time of signature

"timestamp": "1594406341"

signature

String;optional

SKAdNetwork signature as specified by Apple

"signature": "MEQCIEQZRRyMyUXg=="

4.3 Bid Request / Response Samples

4.3.1 Bid request sample

4.3.2 Bid response sample

5.Error Codes

code

Description

200

bid success

10101

http extract filter param is not http.Request"

10102

S2S bid request data empty

10103

Render Common Data error

10201

req_param_filter input error

10202

render bid request data error

10203

Bid Request unit InValidate

10204

Bid Request App InValidate

10205

Bid Request Imp Is Empty

10206

Buyeruid is Empty

10207

Buyeruid data is invalidate

10208

decode bid data error

10210

Bid Request mtg sdk version too low

10301

area target filter input is error

10302

client_ip is invalidate

10303

query netacuity server error

10304

bid in unit and country code blacklist

10401

user agent data filter input error

10501

replace brand model filter input error

10502

replaceBrand params error

10601

render core data filter input error

10602

App not found error

10603

Publisher not found

10604

Unit not found error

10605

Unit ad num set none error

10606

iv orientation invalidate error

10607

iv recallnet invalidate error

10608

renderScreenSize input is error

10609

unit is not active error

10610

unit not found app

10611

app platform error

10612

ad type not support

10613

current app is disable header bidding

10614

illegal sdk version for Google play

10701

build as request filter input is invalidate

10702

compose ad server request error

10703

adserver data json error

10801

traffic sample filter input error

10901

bid adx filter input is error

10902

compose adx http request error

10903

afterbid request is not 200

10904

bid response has no ad

10905

bid adx http do error

10906

bid adx read resp error

10907

bid adx decode resp error

10908

decode Dsp ext error

10909

real time bidding price error

11001

bid cache filter input error

11002

bid cache error

11003

bid imp id error

11101

format output filter input error

Last updated

Was this helpful?