This how-to guide covers the original approach for integrating the Prebid SDK into your app with the GMA SDK. It utilizes:
If you do not have GMA SDK in the app, refer to the Google Integration Documentation.
Another way to integrate GAM into your app is with the Prebid-Rendered Integration.
Tradeoffs between these integration approaches:
Aspect | Bidding-Only Integration | Prebid-Rendered Integration |
---|---|---|
App code has direct access to bids | ![]() |
|
Support for MRAID 3.0 | ![]() |
|
Support for SKAdnetwork | ![]() |
|
Loads data from Prebid Cache | ![]() |
|
Supports instream video | ![]() |
|
Triggers billing and Notice URLs | ![]() |
|
Supports Third Party Rendering libraries | ![]() |
Notes:
The GAM Bidding-Only Integration method assumes that you have the following components:
Here’s how the ad bidding-auction-rendering process works in this integration scenario.
Assuming your app already has AdUnits integrated with the GMA SDK, the technical implementation of Prebid mobile into your app will involve these major steps:
The Ad Operations team will need to create line items in GAM. The creatives used depend on which media formats your adunits utilize.
AdUnit Format | Line Item Targeting | Creative Type | Prebid Cache? | Ad Ops Details |
---|---|---|---|---|
HTML banner, interstitial banner | hb_pb hb_format=banner |
3rd party HTML that loads the PUC | yes | link |
Video (instream, non-instream, interstitial) | hb_pb hb_format=video inventoryType in (instream, mobile app) |
VastUrl pointing to Prebid Cache | yes | link |
Rewarded Video | hb_pb hb_format=video inventoryType in (instream, mobile app) rewarded adunits |
VastUrl pointing to Prebid Cache | yes | link |
In-app native | hb_pb hb_format=native |
GAM native | no | link |
In-Webview native | hb_pb hb_format=native |
3rd party HTML that loads the native-trk script. | yes | link |
Notes:
This information may be useful when comparing data across various reporting systems:
Scenario | PUC | VastUrl Creative | GAM Native Creative |
---|---|---|---|
Rendering Method | PUC in iframe | GMA SDK player | App code with data from PBSDK |
Fires Prebid win event | always | never | always |
Fires Prebid imp event | never | VAST impression tag | never |
Fires OpenRTB burl | when in view | n/a | never (1) |
Fires OpenRTB nurl | always | n/a | always |
Fires OpenMeasurement events | GMA SDK | n/a | PB SDK |
Notes:
This section describes the integration details for different ad formats. In each scenario, you’ll be asked for a configId
- this is a key established in conjunction with your Prebid Server provider. It’s used at runtime to pull in the bidders and parameters specific to this adunit. Depending on your Prebid Server partner, it may be a UUID or constructed out of parts like an account number and adunit name.
Each ad unit in the Original API is a subclass of the AdUnit
class, which provides the following properties and methods for additional configuration.
If set on a given Prebid Mobile ad unit, the fetchDemand
function will be called every periodMillis
until stopAutoRefresh
is called. Each call to fetchDemand
will invoke the onComplete
function. This refresh only pertains to Prebid Mobile and not to any ad server refresh processes. It is suggested that the adServers refresh be turned off.
Parameters
periodMillis
: Integer defining the refresh time in milliseconds.Starts the auto-refresh behavior for a given Prebid Mobile ad unit.
Halts the auto-refresh behavior for a given Prebid Mobile ad unit. If no auto-refresh behavior has been set, stopAutoRefresh
will be ignored.
(requires SDK v2.1.6)
The Global Placement ID (GPID) is a key that uniquely identifies a specific instance of an adunit. Some bidders require this value. An important scenario is “infinite scroll” – if your app creates instances of an adunit dynamically as the user scrolls through content, the the GPID must be different for each by appending some kind of sequence or ID. e.g. “/newsfeed#7”
Using the following method, you can set the impression-level GPID value to the bid request:
adUnit?.gpid = "/36117602/hnp-sfgate.com/Homepage/AP300"
In the Bidding Only integration scenario, PUC is responsible for tracking events for banner ads, like burl
, imp
, and win
. The disadvantage of this approach is that PUC doesn’t have reliable information about the viewability of the WebView. As a result, impression tracking happens at the rendering stage of the ad. Or, if MRAID is supported, once the viewableChange
event is fired. It leads to big discrepancies since the “1 pixel in view” requirement is not met.
Starting with version 2.4.0
, Prebid SDK introduced the API to track the viewability of the ad and track impression event, respectively.
To activate impression tracking for the banner ad unit - use the activatePrebidImpressionTracker(adView)
method. The adView
parameter should be an instance of AdManagerAdView:
adUnit.activatePrebidImpressionTracker(adView)
adUnit.fetchDemand(builder, resultCode -> { ... })
For activation for the interstitial ad unit, you should set activatePrebidImpressionTracker()
flag:
Interstitial adUnit = InterstitialAdUnit(CONFIG_ID, WIDTH, HEIGTH);
adUnit.activatePrebidImpressionTracker();
After the invocation of activatePrebidImpressionTracker(),
the Prebid SDK will start analyzing the View Hierarchy and track the viewability of the ad view. Once the ad view is viewable for the user for at least 1 pixel for 1 second, the SDK will track an impression event for the presented ad. The SDK will stop analyzing the View Hierarchy once the caller object of activatePrebidImpressionTracker()
is destroyed.