Player + page prebid implementation
This is the recommended way we would suggest you implement your prebid implementation with our Targetvideo player. It's a combination of a prebid on site with some minor customization on the player level.
The main advantage of this implementation is that you don't have to change any present Targetvideo embed codes and the player will work with your already present prebid setup on your page if it exists.
If you plan on using this implementation, you will do all the prebid implementation on your page while sending a single reference to the player.
Example of implementation in Targetvideo CMS under the player settings screen
The main difference here is that you need to tell the player which prebid ad unit (in this case "video-1") you are using on your page.
This is best explained with an example:
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<!-- prebid.js -->
<script src="https://acdn.adnxs.com/prebid/not-for-prod/prebid.js"></script>
<!-- Brid Player -->
<script type="text/javascript" src="//<<services_domain>>/player/build/<<player_script>>"></script>
<script>
var PREBID_TIMEOUT = 2000;
var FAILSAFE_TIMEOUT = 3000;
var adUnits = [
{
code: 'video-1', // use this code in the CMS
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'instream'
}
},
bids: [{
bidder: 'appnexus',
params: {
placementId: 13232361,
video: {
skippable: true,
playback_method: ['auto_play_sound_off']
}
}
}]
}
];
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
pbjs.que.push(function() {
pbjs.addAdUnits(adUnits);
pbjs.setConfig({
cache: {
url: 'https://prebid.adnxs.com/pbc/v1/cache'
}
});
pbjs.requestBids({
bidsBackHandler: initAdserver,
timeout: PREBID_TIMEOUT
});
});
function initAdserver() {
if (pbjs.initAdserverSet) return;
pbjs.initAdserverSet = true;
var bids = pbjs.getBidResponses();
console.log('Prebid bids are back', pbjs.getBidResponses()); // bids are back, now we're requesting VAST URL for video unit
for (var i in adUnits) { // going through adUnits array
if (adUnits[i].code == 'video-1' && bids['video-1']) { // searching for video unit. THIS IS THE AD UNIT YOU NEED TO ENTER IN YOUR BRID PLAYER SETTINGS AREA.
var vastUrl = pbjs.adServers.dfp.buildVideoUrl({ // generating VAST URL
adUnit: adUnits[i],
params: {
iu: '/19968336/prebid_cache_video_adunit',
cust_params: {
section: 'blog',
anotherKey: 'anotherValue'
},
output: 'vast'
}
});
adUnits[i].vastUrl = vastUrl; // setting it to adUnits, Brid player will grab it from there
console.log('Prebid setting vastUrl on page', vastUrl);
}
}
googletag.cmd.push(function() {
pbjs.que.push(function() {
pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
});
}
// in case PBJS doesn't load
setTimeout(function() {
initAdserver();
}, FAILSAFE_TIMEOUT);
</script>
<script type="text/javascript" src="https://services.brid.tv/player/build/brid.min.js"></script>
<div id="DIV_ID" class="brid" style="width:480;height:270;" > </div>
<script type="text/javascript"> $bp("DIV_ID", {"id":"PLAYER_ID","width":"480","height":"270","video":"VIDEO_ID"}); </script>
You can also view a complete working example using this implementation HERE
This demo shows how the player can work with both video + display banner header bidding together.
Tip
You can override the player size which is sent to prebid by setting the following JavaScript variable on your page
Example:
var prebidPlayerSize<<company>> = [640, 480];
By default the player caches bid responses for better performance but you can override this setting by adding the following code to your web page:
var prebidConfig<<company>> = {useBidCache: false};
Updated almost 2 years ago