Utilizzo del CMP con prebid.js

Per utilizzare il CMP con prebid.js è necessario compilare prebid.js nella versione 1.0 o superiore (la versione 0.3x di prebid.js non supporta i CMP). Puoi scaricare la versione precompilata da http://prebid.org/download.html oppure compilarla tu stesso (scarica da https://github.com/prebid/Prebid.js, compila tramite gulp build –modules=consentManagement,bidAdapter1,bidAdapter2,…).

  1. Aggiungi il normale codice CMP al tuo sito web
  2. Inserisci il file prebid.js nella tua directory web e aggiungi gli script di configurazione per prebid.js al tuo sito web
  3. Aggiungi una configurazione consentManagement di prebid.js alla normale configurazione di prebid.js in questo modo:
<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>

We do our best to keep this purely informative documentation up to date. However, if you notice that any of these guides need a little touch-up, let us know!