Info
Innehåll

Använda CMP med prebid.js

För att kunna använda CMP med prebid.js måste du bygga prebid.js i version 1.0 eller senare (version 0.3x av prebid.js stöder inte CMP). Du kan ladda ner förbyggnadsversionen från http://prebid.org/download.html eller bygg det själv (ladda ner från https://github.com/prebid/Prebid.js, bygga via gulp build - moduler = godkännandeManagement, bidAdapter1, bidAdapter2, ...).

  1. Lägg till den normala CMP-koden på din webbplats
  2. Placera prebid.js-filen i din webbkatalog och lägg till konfigurationsskript för prebid.js på din webbplats
  3. Lägg till en prebid.js samtyckeHantering konfigurera till den normala prebid.js-konfigurationen så här:
<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>
Tillbaka till toppen