clickio

Google render event

Apr 27th, 2020
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function(){
  2.     var adName = ["clickio_area_%id%"]; // ~ ad slot id
  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.  
  15.         googletag.pubads().addEventListener("slotRenderEnded", function(event){
  16.             var slotId = event.slot.getSlotId().getId();
  17.             if(checkSlot(slotId) && event.slot.getResponseInformation())
  18.             {
  19.                 // there you can check elements height
  20.             }
  21.         });
  22.  
  23.         googletag.pubads().addEventListener("slotResponseReceived", function(event){
  24.             var slotId = event.slot.getSlotId().getId();
  25.             if(checkSlot(slotId))
  26.             {
  27.                 if(!event.slot.getResponseInformation())
  28.                 {
  29.                     // if unsold - sticky can be hidden
  30.                 }
  31.             }
  32.         });
  33.     });
  34. })();
Add Comment
Please, Sign In to add comment