Prebid Server improves your page’s performance by running the header bidding auction on a server. This will improve your page’s load time, which should improve your users’ experience.
Prebid Server supports different adapters from Prebid.js. For info about Prebid Server adapters, see the Prebid Server Bidders page.
Prebid Server is open source! Prebid Server is an open source project. The source code is hosted under the Prebid organization on GitHub.
If you plan to host Prebid Server on your own server, please skip to Step 2 below. If you do not have your own server, please choose from one of the Prebid.org members below to get started.
accountId
. You will need this for configuring Prebid.js to use Prebid Server.Update your site’s hosted copy of Prebid.js to use the new build you just generated. (For example, you may host your copy on your site’s servers or using a CDN such as Fastly or Akamai.)
The Prebid Server settings (defined by the pbjs.setConfig
method) go in the same anonymous function where you define your ad units. This method must be called before pbjs.requestBids
.
The code in your Prebid configuration block should look something like the following (unless you want to show video ads, in which case see Using Prebid Server to show video ads below).
See The s2sConfig
object for definitions of the keys in the s2sConfig
object.
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
pbjs.que.push(function() {
pbjs.setConfig({
s2sConfig: {
accountId: '1',
enabled: true,
bidders: ['appnexus', 'pubmatic'],
timeout: 1000,
adapter: 'prebidServer',
endpoint: 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction',
syncEndpoint: 'https://prebid.adnxs.com/pbs/v1/cookie_sync'
}
});
var adUnits = [{
code: '/19968336/header-bid-tag-1',
sizes: sizes,
bids: [{
/* Etc. */
}]
}];
});
Optionally, if you chose to use one of the existing Prebid.org members as your server host, you can also use the defaultVendor property. This property represents the vendor’s default settings for the s2sConfig. When used, these settings will be automatically populated to the s2sConfig, saving the need to individually list out all data points. Currently ‘appnexus’ and ‘rubicon’ are supported values.
These defaults can still be overridden by simply including the property with the value you want in the config. The following example represents the bare minimum configuration required when using the defaultVendor option:
var pbjs = pbjs || {};
pbjs.que.push(function() {
pbjs.setConfig({
s2sConfig: {
accountId: '1',
bidders: ['appnexus', 'pubmatic'],
defaultVendor: 'appnexus'
}
});
var adUnits = [{
code: '/19968336/header-bid-tag-1',
sizes: sizes,
bids: [{
/* Etc. */
}]
}];
});
OpenRTB Endpoint
If your s2sConfig.endpoint
points to a url containing the path /openrtb2/
, such as the AppNexus-hosted endpoint https://prebid.adnxs.com/pbs/v1/openrtb2/auction’, Prebid will communicate with that endpoint using the OpenRTB protocol.
Aliasing Prebid Server only bidders
If you wish to set/use an alias for a Prebid Server only bidder, simply list the alias in your s2sConfig.bidders
field and call the pbjs.aliasBidder
method in your prebid code (prior to the pbjs.requestBids
) to register the alias.
If you are using Prebid Server and you want to show video ads, you must use OpenRTB video parameters in your Prebid ad unit as shown below.
The mimes
parameter is required by OpenRTB. For all other parameters, check with your server-side header bidding partner.
var adUnit1 = {
code: 'videoAdUnit',
mediaTypes: {
video: {
context: 'instream',
mimes: ['video/mp4'],
playerSize: [400, 600],
minduration: 1,
maxduration: 2,
protocols: [1, 2],
w: 1,
h: 2,
startdelay: 1,
placement: 1,
playbackmethod: [2]
// other OpenRTB video params
}
},
bids: [
// ...
]
}