Easy Steps for Prebid.js
Steps for Prebid.js
For the benefit of publishers we have already hosted build prebid.js. Following are the easy steps to start prebid.js:
- Create a prebid.js file with the chosen list of header bidding partners
- You can download the prebid.js from this link – https://prebid.org/download.html
- Upload the prebid.js file on your website or other server
- In the page header code, specify the domain in the pbs.src code
For example: pbs.src = ‘//abc123.com/prebid.js’;
A) Add the following code in the page header:
Code Snippet:
Head Tag
<script> (function() { var d = document, pbs = d.createElement(‘script’), pro = d.location.protocol; pbs.type = ‘text/javascript’; pbs.src = ‘//test1.incrementx.com/build/dev/prebid.js’; var target = document.getElementsByTagName(‘head’)[0]; target.insertBefore(pbs, target.firstChild); })(); var pbjs = pbjs || {}; pbjs.que = pbjs.que || []; pbjs.que.push(function() { var adUnits = [{ code: ‘vz_hb_slot1’, sizes: [[300, 250]], bids: [{ bidder: ‘appnexus’, params: { placementId: ‘4799418’ } }, { bidder: ‘incrementx’, params: { placementId:’VZ-HB-M853211V2DED19′ } }] }, { code: ‘vz_hb_slot2’, sizes: [[300, 250]], bids: [{ bidder: ‘appnexus’, params: { placementId: ‘4799418’ } }, { bidder: ‘incrementx’, params: { placementId: ‘njkn’ } }] }]; pbjs.addAdUnits(adUnits); pbjs.requestBids({ bidsBackHandler: function(bidResponses) { var targetingParams = pbjs.getAdserverTargeting(); //—object based on div—–// var adSpaceSlot1=targetingParams.vz_hb_slot1; var adSpaceSlot1=targetingParams.vz_hb_slot2; // ———extract ad id —- // var adid1= adSpaceSlot1.hb_adid; var adid2= adSpaceSlot2.hb_adid; //create frame to display repeated for frames //to display ads on server var frame1 = document.getElementById(‘vz_hb_frame1’); frame1.contentWindow.document.open(‘text/html’,’replace’); frame1.contentWindow.document.write(‘<script>var curr_w = parent.window;console.log(‘+'”‘+adid1+'”‘+’);for (i = 0; i < 10; i++) { try {curr_w.pbjs.renderAd(document, ‘+'”‘+adid1+'”‘+’); break;}catch(e) {console.log(e.message);continue;}}</s’+’cript>’); frame1.contentWindow.document.close(); } }); }); </script> |
B) Add the following code in the page body:
Code Snippet:
Body Tag:
<div id = “vz_hb_slot1”> <iframe id=”vz_hb_frame1” src=”javascript:'<html><body></body></html>’” frameborder=”0” marginwidth=”0” marginheight=”0” scrolling=”NO” width=”300” height=”250“></iframe> </div> <div id = “vz_hb_slot2”> <iframe id=”vz_hb_frame2” src=”javascript:'<html><body></body></html>’” frameborder=”0” marginwidth=”0” marginheight=”0” scrolling=”NO” width=”300” height=”250“></iframe> </div> |