This document describes the changes to the Publisher API for Prebid.js version 1.0.
pbjs.setConfig
The following functions and variables were removed as of 1.0:
pbjs._*
variables, including:
pbjs._winningBids
pbjs._bidsReceived
pbjs._bidsRequested
pbjs._adUnitCodes
pbjs._adsReceived
pbjs.cbTimeout
pbjs.addCallback
and pbjs.removeCallback
in favor of the onEvent APIpbjs.allBidsAvailable
pbjs.buildMasterVideoTagFromAdserverTag
in favor of pbjs.adServers.dfp.buildVideoUrl
adUnit.sizeMapping
in favor of pbjs.setConfig({sizeConfig:[ ... ]})
Other methods were removed as part of the new setConfig
API - for details, see the section below describing the new pbjs.setConfig
API.
For a complete list of methods that were removed, see the Publisher API Reference.
pbjs.setConfig
For 1.0, the following APIs were removed in favor of a generic “options” param object passed to pbjs.setConfig
:
pbjs.bidderTimeout
- use pbjs.setConfig({bidderTimeout})
insteadpbjs.logging
- use pbjs.setConfig({debug})
insteadpbjs.publisherDomain
- use pbjs.setConfig({publisherDomain})
insteadpbjs.setPriceGranularity
- use pbjs.setConfig({priceGranularity})
insteadpbjs.enableSendAllBids
- use pbjs.setConfig({enableSendAllBids})
instead. Now defaults to true
.pbjs.setBidderSequence
- use pbjs.setConfig({bidderSequence})
insteadpbjs.setS2SConfig
- use pbjs.setConfig({s2sConfig})
insteadpbjs.setConfig
ExampleThe input to pbjs.setConfig
must be JSON (no JavaScript functions are allowed).
In Prebid 0.x there were defaults for the Prebid Server endpoints and the video cache URL. With 1.0, these defaults have been removed to be vendor neutral, so all publisher pages must define them via pbjs.setConfig()
. The same functionality as 0.x may be achieved as shown below:
The previous sizeMapping
functionality was removed and replaced by a sizeConfig
parameter to the pbjs.setConfig
method that provides a more powerful way to describe types of devices and
screens.
If sizeConfig
is passed to pbjs.setConfig
:
Before requestBids
sends bids requests to adapters, it will evaluate and pick the appropriate label(s) based on the sizeConfig.mediaQuery
and device properties and then filter the adUnit.bids
based on the labels
defined (by dropping those ad units that don’t match the label definition).
The sizeConfig.mediaQuery
property allows media queries in the form described here. They are tested using the window.matchMedia
API.
If a label conditional (e.g. labelAny) doesn’t exist on an ad unit, it is automatically included in all requests for bids.
If multiple rules match, the sizes will be filtered to the intersection of all matching rules’ sizeConfig.sizesSupported
arrays.
The adUnit.sizes
selected will be filtered based on the sizesSupported
property of the matched sizeConfig
. So the adUnit.sizes
is a subset of the sizes defined from the resulting intersection of sizesSupported
sizes and adUnit.sizes
.
sizeConfig
ExampleTo set size configuration rules, you can pass sizeConfig
into pbjs.setConfig
as follows:
Labels can now be specified as a property on either an adUnit
or on adUnit.bids[]
. The presence of a label will disable the adUnit or bidder unless a sizeConfig rule has matched and enabled the label or the label has been enabled manually by passing them into through requestBids: pbjs.requestBids({labels:[]})
.
Labels may be targeted in the AdUnit structure by two conditional operators: labelAny
and labelAll
.
With the labelAny
operator, just one label has to match for the condition to be true. In the example below, either A or B can be defined in the label array to activate the bid or ad unit:
With the labelAll
conditional, every element of the target array must match an element of the label array in
order for the condition to be true. In the example below, both A and B must be defined in the label array to activate the bid or ad unit:
Only one conditional may be specified on a given AdUnit or bid – if both labelAny
and labelAll
are specified, only the first one will be utilized and an error will be logged to the console. It is allowable for an AdUnit to have one condition and a bid to have another.
If either labelAny
or labelAll
values is an empty array, it evaluates to true
.
Defining labels on the adUnit looks like the following:
See Conditional Ad Units for additional use cases around labels.
If an adUnit and/or adUnit.bids[] bidder has labels defined, they will be disabled by default. Manually setting active labels through pbjs.requestBids()
will enable the selected adUnits and/or bidders.
You can manually turn on labels using the following code:
The mediaType
attribute has been removed in favor of a mediaTypes
object. This object accepts multiple properties (i.e. video
, banner
, native
etc) with an optional key-value pair object nested inside, e.g.: