Prebid
The moli ad tag library natively integrates with prebid.js.
Enable prebid
You enable prebid by setting a PrebidConfig in your ad tag MoliConfig. The library will take of setting the configuration for prebid.
Configuration properties
The prebid config object contains configurations from pbjs and moli itself.
bidderSettings- set thepbjs.bidderSettingsconfig- will be set viapbjs.setConfig()
See a full list of properties in the PrebidConfig API doc
Example
This is a small config with some parameters configured
{
slots: [ /* ... */],
prebid: {
// the full prebid config which is set via pbjs.setConfig()
config: {
bidderTimeout: 1000,
consentManagement: {
timeout: 500,
allowAuctionWithoutConsent: true
},
floors: {
enforcement: {
enforceJS: false
}
},
userSync: {
userIds: [ ]
},
currency: {
adServerCurrency: 'EUR'
}
}
}
}
Sizes & Labels
The ad tag filters the sizes provider in mediaType.banner.sizes and mediaType.video.playerSize based on
the given sizeConfigs.
Labels can be used in a bid object like in prebid to filter a bid based on available labels
Consent behaviour
Prebid won't be called before the consent state is ready. The cmpTimeout setting has no effect.
Ad Slot
You enable prebid for a single ad slot by setting the prebid property.
The value is a PrebidAdSlotConfigProvider, which can be
either a static value or function that allows more dynamic behaviour.
The PrebidAdSlotConfigProvider returns a single or an array
of PrebidAdSlotConfig objects. They provide an prebidjs.IAdUnit
that hosts a standard prebidjs ad unit.
Example: single ad unit
This is a standard ad slot with a single prebid bid object
{
position: 'in-page',
domId: 'content_1',
behaviour: { loaded: 'eager' },
adUnitPath: '/123,456/content_1',
sizes: [[300, 250], [728, 90], 'fluid'],
prebid: {
adUnit: {
mediaTypes: {
banner: {
sizes: [[300,250], [728, 90]]
}
},
bids: [
{ bidder: 'criteo' , params: { networkId: 123, publisherSubId: 'content_1' }}
]
}
},
sizeConfig: [
{
mediaQuery: '(man-width: 767px)',
sizesSupported: [[300, 250], 'fluid']
},
{
mediaQuery: '(min-width: 768px)',
sizesSupported: [[728,90], 'fluid']
}
]
}
Example: Twin ad units
Twin ad units are supported.
The prebid property may return an array of ad units.
{
position: 'in-page',
domId: 'content_1',
behaviour: { loaded: 'eager' },
adUnitPath: '/123,456/content_1',
sizes: [[300, 250], [728, 90], 'fluid'],
prebid: [
{
adUnit: {
mediaTypes: {
banner: { sizes: [[300,250], [728, 90]]}
},
bids: [{ bidder: 'criteo' , params: { networkId: 123, publisherSubId: 'content_1' }}]
}
},
{
adUnit: {
mediaTypes: {
video: { /* video settings */}
},
bids: [{ bidder: 'video-bidder' , params: { placementId: 'content_1' }}]
}
}
],
sizeConfig: [
{
mediaQuery: '(man-width: 767px)',
sizesSupported: [[300, 250], 'fluid']
},
{
mediaQuery: '(min-width: 768px)',
sizesSupported: [[728,90], 'fluid']
}
]
}
Example: Dynamic ad unit
Sometimes you want to do something before creating prebid ad unit objects.
The receives a PrebidAdSlotContext, which grants access
to ad slot specific properties.
{
position: 'in-page',
domId: 'content_1',
behaviour: { loaded: 'eager' },
adUnitPath: '/123,456/content_1',
sizes: [[300, 250], [728, 90], 'fluid'],
prebid: context => ({
adUnit: {
mediaTypes: {
banner: {
sizes: [[300,250], [728, 90]]
}
},
bids: [
{
bidder: 'appNexus' ,
params: {
placmenentId: 123,
keywords: { iab1: context.keyValues.iab1 ?? 'none'}
}
}
]
}
}),
sizeConfig: [
{
mediaQuery: '(man-width: 767px)',
sizesSupported: [[300, 250], 'fluid']
},
{
mediaQuery: '(min-width: 768px)',
sizesSupported: [[728,90], 'fluid']
}
]
}