Between Digital


Инструкция по подключению Prebid.js вместе с Google DFP

Шаг 1: Сборка Prebid.js

Вариант 1: на сайте Prebid.js. Перейдите на сайт prebid.org/download.html , выберите в списке адаптер BetweenDigital, нажмите кнопку «Get Prebid.js!» внизу страницы.

Вариант 2: на сайте Github. Перейдите на сайт github и соберите Prebid согласно инструкции.

Шаг 2: Установка Prebid на странице вместе с Google DFP

В качестве примера используются параметры:

Вы также можете указать несколько размеров в параметре mediaTypes.banner.sizes, например:

        
mediaTypes: {
  banner: {
      sizes: [[240, 400], [300, 250], [300,600]],
  }
}, 
        
      

  1. Предварительно настройте Google DFP по инструкции
  2. Подключите в <head> собранный prebid.js: <script src="prebid.js></script>
  3. Вставьте в <head> следующий код:
  4.     
          
          
          
          
          
          
          
        
      
  5. Вставте в <body> следующий код:
  6.     
    

Полный пример:

    
<!DOCTYPE html>
<html lang="ru">
<head>
<script type="text/javascript" src="prebid.js">
</script>

<script>
  var PREBID_TIMEOUT = 1000;
  var adUnits = [{
    code: 'div-gpt-ad-1576579925364-0',
    sizes: [[240, 400]],
    bids: [
    {
      bidder: 'between',
      params: {
        s: 3649326,
        cur: 'EUR'
      }
    }
]
}];

  var pbjs = pbjs || {};
  pbjs.que = pbjs.que || [];

  pbjs.que.push(function() {
  pbjs.setConfig({
    priceGranularity: {
      "buckets": [{
          "precision": 2,
          "min": 0,
          "max": 10,
          "increment": 5.00
      }, {
          "precision": 2,
          "min": 10,
          "max": 20,
          "increment": 10.00
      }, {
          "precision": 2,
          "min": 20,
          "max": 100,
          "increment": 20.00
      },{
          "precision": 2,
          "min": 100,
          "max": 200,
          "increment": 50.00
      }, {
          "precision": 2,
          "min": 200,
          "max": 600,
          "increment": 200.00
      }]
  }
  });
});

</script>

<script>
  var googletag = googletag || {};
  googletag.cmd = googletag.cmd || [];
  googletag.cmd.push(function() {
    googletag.pubads().disableInitialLoad();
});

  pbjs.que.push(function() {
    pbjs.addAdUnits(adUnits);
    pbjs.requestBids({
      bidsBackHandler: sendAdserverRequest
  });
});

function sendAdserverRequest() {
  if (pbjs.adserverRequestSent) return;
    pbjs.adserverRequestSent = true;
    googletag.cmd.push(function() {
      pbjs.que.push(function() {
        pbjs.setTargetingForGPTAsync();
        googletag.pubads().refresh();
    });
  });
}
setTimeout(function() {
        sendAdserverRequest();
}, PREBID_TIMEOUT);
</script>

<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>

<script>
  window.googletag = window.googletag || {cmd: []};
  googletag.cmd.push(function() {
    googletag.defineSlot('/21757675864/240_400', [240, 400], 'div-gpt-ad-1576579925364-0').addService(googletag.pubads());
    googletag.pubads().enableSingleRequest();
    googletag.enableServices();
  });
</script>

</head>
<body>
  <div id='div-gpt-ad-1576579925364-0' style='width: 240px; height: 400px;'>
  <script>
    googletag.cmd.push(function() { googletag.display('div-gpt-ad-1576579925364-0'); });
  </script>
  </div>
</body>
</html>