Prebid.js Adapter Setup for Video
Last updated on September 16, 2019
The OpenX adapter allows OpenX to participate as a demand source within the Prebid container solution using a video player. For more information, see http://prebid.org.
This page guides you through adding OpenX’s Prebid adapter into your existing Prebid implementation. The OpenX adapter for Prebid.js supports in-stream video.
on this page
Implementation
Prior to starting consider the following requirements:
- You must be using Prebid.js version 1.9.0 or later.
- For GDPR support, you must use version 1.11 or later.
To implement Prebid.js adapter for video:
Follow Prebid’s instructions for Setting up Prebid Video in DFP. Be sure to add the OpenX key-value pair values to your line items. The OpenX key-value pair value has the following format:
oxb=size_bid
.Provide answers to the following questions to OpenX:
a. Which inventory do you plan to use?
b. Are you using other adapters?
In addition, work with OpenX to ensure OpenX is listed correctly in your ads.txt file.
Customize and download your prebid.js code. Select OpenX from Select Bidder Adapters and DFP Video from Modules.
Configure
bidder: 'openx'
using the properties in the table below.var videoAdUnit = { code: 'video1', mediaTypes: { video : { playerSize: [640, 480], context: 'instream' } }, bids: [{ bidder: 'openx', params: { unit: '1611023124', delDomain: 'PUBLISHER-d.openx.net', } }] };
Property Type Description Required? delDomain
string
OpenX delivery domain provided by OpenX.<p>For example: PUBLISHER-d.openx.net
Required unit
string
OpenX ad unit ID provided by OpenX.
For example:1611023124
Required openrtb
object
OpenRTB properties. OpenX only supports the following OpenRTB video object properties for use with Prebid (see the IAB’s OpenRTB 2.5 specification):
•mimes
•minduration
•maxduration
•protocols
•protocol
•w
•h
•startdelay
•linearity
•sequence
•battr
•maxextended
•minbitrate
•maxbitrate
•boxingallowed
•playbackmethod
•delivery
•pos
•api
•companiontype
•ext
Optional Add the following code to enable user syncing. OpenX strongly recommends enabling user syncing through iframes, which is turned off by default in Prebid.js version 0.34.0+. This functionality improves DSP user match rates and increases the OpenX bid rate and bid price. Make sure to call
pbjs.setConfig()
only once.Note that Prebid.js version 1.15 implements a different way to enable user syncing through iframes than previous versions. The code below works for both implementations.
pbjs.setConfig({ userSync: { iframeEnabled: true, filterSettings: { iframe: { bidders: ['openx'], filter: 'include' } } } });
Register the ad unit and request bids.
pbjs.que.push(function(){ pbjs.addAdUnits(videoAdUnit); pbjs.setConfig({ cache: { url: 'https://prebid.adnxs.com/pbc/v1/cache' }, userSync: { iframeEnabled: true, filterSettings: { iframe: { bidders: ['openx'], filter: 'include' } } } }); pbjs.requestBids({ timeout: 1500, bidsBackHandler: function(bids) { var videoUrl = pbjs.adServers.dfp.buildVideoUrl({ adUnit: videoAdUnit, params: { iu: '/12345678/DFP_ad_unit', output: 'vast', hl: 'en' } }); invokeVideoPlayer(videoUrl); } }); });
Initialize your player. The following example uses the JW Player video player.
var jwPlayerInstance = jwplayer('playerContainerJW'); invokeVideoPlayer = function(url) { jwPlayerInstance.setup({ file: 'enter video file or use jwPlayer license key', autostart: true, mute: true, advertising: { client: 'vast' } }); jwPlayerInstance.on('beforePlay', function(){ jwPlayerInstance.playAd(url); }); }
Send a test page to OpenX for review.
After OpenX reviews it, deploy this implementation to all your production digital pages.
Full Code Sample
The following code example uses the JW Player video player. However, this solution supports any video player.
Click to expand code sample
<html>
<head>
<!-- prebid.js -->
<script src="prebid.js" async=true></script>
<!-- JWPlayer -->
<script type="text/javascript" src="http://ssl.p.jwpcdn.com/player/v/8.3.5/jwplayer.js">
</script>
<script type="text/javascript">
jwplayer.key="Enter your key";
</script>
<script>
/* Prebid Video adUnit */
var videoAdUnit = {
code: 'video1',
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'instream'
}
},
bids: [{
bidder: 'openx',
params: {
unit: '1611023124',
delDomain: 'PUBLISHER-d.openx.net',
video: {
mimes: ['video/mp4', 'video/x-flv']
}
}]
};
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
pbjs.que.push(function(){
pbjs.addAdUnits(videoAdUnit);
pbjs.setConfig({
cache: {
url: 'https://prebid.adnxs.com/pbc/v1/cache'
},
userSync: {
iframeEnabled: true,
filterSettings: {
iframe: {
bidders: ['openx'],
filter: 'include'
}
}
}
});
pbjs.requestBids({
timeout: 1500,
bidsBackHandler: function(bids) {
var videoUrl = pbjs.adServers.dfp.buildVideoUrl({
adUnit: videoAdUnit,
params: {
iu: '/90577858/test_ox_prebid_video',
output: 'vast',
hl: 'en'
}
});
invokeVideoPlayer(videoUrl);
}
});
});
</script>
</head>
<body>
<div id='playerContainerJW' style='width:640px; height:480px; border:1px solid black;'>
</div>
<script>
var jwPlayerInstance = jwplayer('playerContainerJW');
invokeVideoPlayer = function(url) {
jwPlayerInstance.setup({
file: 'enter video file or jwPlayer license key',
autostart: true,
mute: true,
advertising: {
client: 'vast'
}
});
jwPlayerInstance.on('beforePlay', function(){
jwPlayerInstance.playAd(url);
});
}
</script>
</body>
</html>