Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: Prebid Server and Postbid integration example ( ad server-less ) #6348

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions integrationExamples/postbid/postbid_prebidServer_example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<html>
<head>
<script>

var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
(function() {
var pbjsEl = document.createElement("script");
pbjsEl.type = "text/javascript";
pbjsEl.async = true;
pbjsEl.src = '../../build/dev/prebid.js';
var pbjsTargetEl = document.getElementsByTagName("head")[0];
pbjsTargetEl.insertBefore(pbjsEl, pbjsTargetEl.firstChild);
})();

pbjs.que.push(function() {
var adUnits = [{
code: 'postbid_iframe',
mediaTypes: {
banner: {
sizes: [[300, 250]]
}
},
bids: [
{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}
]
}];

pbjs.setConfig({
bidderTimeout: 1000,
s2sConfig : {
accountId : '1',
enabled : true, //default value set to false
bidders : ['appnexus'],
timeout : 1000, //default value is 1000
adapter : 'prebidServer', //if we have any other s2s adapter, default value is s2s
endpoint : 'https://prebid.adnxs.com/pbs/v1/openrtb2/auction'
}
});

pbjs.addAdUnits(adUnits);

pbjs.requestBids({
bidsBackHandler: function(bidResponses) {
var iframe = document.getElementById('postbid_iframe');
var iframeDoc = iframe.contentWindow.document;
var adServerTargeting = pbjs.getAdserverTargetingForAdUnitCode('postbid_iframe');

// If any bidders return any creatives
if (adServerTargeting && adServerTargeting['hb_adid']) {
pbjs.renderAd(iframeDoc, adServerTargeting['hb_adid']);
} else {
iframe.width = sizes[0][0];
iframe.height = sizes[0][1];
iframeDoc.write('<head></head><body>' + passbackTagHtml + '</body>');
iframeDoc.close();
}
}
})
});

var passbackTagHtml = 'TO ADD';
</script>

</head>

<body>
<iframe id='postbid_iframe'
FRAMEBORDER="0"
SCROLLING="no"
MARGINHEIGHT="0"
MARGINWIDTH="0"
TOPMARGIN="0"
LEFTMARGIN="0"
ALLOWTRANSPARENCY="true"
WIDTH="0"
HEIGHT="0">
</iframe>

</body>
</html>