Using Prebid.
js
Step 1: Building [Link]
Option 1: on [Link] website. Go to [Link] «Get [Link]!» at the bottom of the page.
Option 2: from Github. Go to github and build sources according to instructions.
Step 2: Setup Prebid on a website
The parameters are used as an example:
s: 3649326 — Between section id
code: ad_slot — id of a iframe element showing prebid ads
1. Include into <head> builded [Link]: <script src="[Link]></script>
2. Include into <head> following code:
<script>
var PREBID_TIMEOUT = 1000;
var adUnits = [{
code: 'ad_slot',
mediaTypes: {
banner: {
sizes: [[240, 400]],
}
},
bids: [
{
bidder: 'between',
params: {
s: 3649326,
}
}
]
}];
var pbjs = pbjs || {};
[Link] = [Link] || [];
</script>
<script>
[Link](function() {
[Link](function () {
[Link]({userSync: {
iframeEnabled:true
}})
});
[Link](adUnits);
[Link]({
bidsBackHandler: sendAdserverRequest
});
});
function sendAdserverRequest() {
if ([Link]) return;
[Link] = true;
var params = [Link]('ad_slot');
var iframe = [Link]('ad_slot');
var iframeDoc = [Link];
if(params && params['hb_adid']) {
[Link](iframeDoc, params['hb_adid']);
}
}
setTimeout(function() {
sendAdserverRequest();
}, PREBID_TIMEOUT);
</script>
3. Include into <body> this code: <iframe id="ad_slot"></iframe>
Currency
You can choose in which currency the SSP server will send cpm: 'USD' or 'EUR'. Default is 'USD'. To do this, in the params field of our adapter you need
to add the cur field, which takes one of the values: 'USD' or 'EUR'.
For example, you want cpm to be sent in dollars. Then the code of our adapter settings will look like this:
{
bidder: 'between',
params: {
s: BETWEEN_SECTION_ID,
cur: 'USD'
}
}
Multisizes
If you specify several sizes in the AdUnits settings in the [Link] field, our SSP server will hold an auction with each size and respond
with a bid with the maximum CPM. For example, your ad-slot supports three sizes: 970x250, 728x90 and 468x60. Then the AdUnits code will look like this:
var adUnits = [{
code: 'ad-slot',
mediaTypes: {
banner: {
sizes: [[970, 250], [728, 90], [468, 60]]
}
},
bids: [
{
bidder: 'between',
params: {
s: BETWEEN_SECTION_ID,
}
}
]
}];
Full example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" />
<title>Prebid Test</title>
<script src="[Link]"></script>
<script>
var PREBID_TIMEOUT = 1000;
var adUnits = [
{
code: "ad_slot",
mediaTypes: {
banner: {
sizes: [[970, 250]]
}
},
bids: [
{
bidder: "between",
params: {
s: 3635454
}
}
]
}
];
var pbjs = pbjs || {};
[Link] = [Link] || [];
</script>
<script>
[Link](function() {
[Link](function() {
[Link]({
userSync: {
iframeEnabled: true
}
});
});
[Link](adUnits);
[Link]({
bidsBackHandler: sendAdserverRequest
});
});
function sendAdserverRequest() {
if ([Link]) return;
[Link] = true;
var params = [Link]("ad_slot");
var iframe = [Link]("ad_slot");
var iframeDoc = [Link];
if (params && params["hb_adid"]) {
[Link](iframeDoc, params["hb_adid"]);
}
}
setTimeout(function() {
sendAdserverRequest();
}, PREBID_TIMEOUT);
</script>
</head>
<body>
<iframe id="ad_slot"></iframe>
</body>
</html>