Info
Content

Using the CMP with prebid.js

In order to use the CMP with prebid.js you need to build prebid.js in version 1.0 or above (version 0.3x of prebid.js don’t support CMPs). You can download the prebuild version from http://prebid.org/download.html or build it yourself (download from https://github.com/prebid/Prebid.js, build via gulp build --modules=consentManagement,bidAdapter1,bidAdapter2,…).

  1. Add the normal CMP code to your website
  2. Place the prebid.js file in your web directory and add the configuration scripts for prebid.js to your website
  3. Add a prebid.js consentManagement config to the normal prebid.js configuration like this:
<script>
  var PREBID_TIMEOUT = 300;
  var pbjs = pbjs || {};
  pbjs.que = pbjs.que || [];
  pbjs.que.push(function()
                { 
    pbjs.setConfig( { consentManagement: 
                     { cmpApi: 'iab', //needs to be iab   
                       timeout: 8000, //timeout for prebid to wait for consent in ms   
                       allowAuctionWithoutConsent: true //send requests without consent?  
                     } 
                    });                               
    var units = []; 
    units[units.length] = {  
      code: "content",  
      sizes: [[300, 250]],  
      bids: [   
        {bidder: "criteo", params: {zoneId: "..."}},   
        {bidder: "fidelity", params: {zoneid: "...", floor: 0.05, server: "..."}},   
        {bidder: "stroeerCore", params: {sid: "..."}}   
        //more bidders here  
      ] }; 
    pbjs.addAdUnits(units); 
    pbjs.timeout = 300; 
    pbjs.requestBids({ bidsBackHandler: function(bidResponses){ }, timeout: 300 });
  });
</script>
Back to top