Advertisement
clickio

Creative unsold check

Mar 30th, 2020
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function(){
  2.     var adName = ["clickio_area_638007_336x280"]; // <- сюда пишем массив проверяемых слотов google, может быть достаточно одного
  3.  
  4.     var checkSlot = function(slotId) {
  5.         return adName.some(function(adName) {
  6.             return slotId.indexOf(adName) !== -1;
  7.         });
  8.     };
  9.  
  10.     window.googletag = window.googletag || {};
  11.     window.googletag.cmd = window.googletag.cmd || [];
  12.  
  13.     googletag.cmd.push(function() {
  14.         googletag.pubads().addEventListener("slotResponseReceived" /*"slotRenderEnded"*/, function(event){
  15.             var slotId = event.slot.getSlotId().getId();
  16.             if(checkSlot(slotId))
  17.             {
  18.                 if(!event.slot.getResponseInformation())
  19.                 {
  20.                     /* здесь код, отрабатывающий, если невыкуп*/
  21.                 }
  22.                 else
  23.                 {
  24.                     /* если всё хорошо тут берём высоту элемента и подставляем куда нужно отступ */
  25.                 }
  26.             }
  27.         });
  28.     });
  29. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement