SHARE
TWEET

GAM360 Responsive Header

gbKyle Feb 26th, 2020 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script async='async' src='https://www.googletagservices.com/tag/js/gpt.js'></script>
  2. <script>
  3.   var googletag = googletag || {};
  4.   googletag.cmd = googletag.cmd || [];
  5. </script>
  6. <script>
  7.  
  8.  
  9.  
  10.  googletag.cmd.push(function() {
  11.  
  12.  
  13.  
  14.    googletag.pubads().enableSingleRequest();
  15.    googletag.pubads().setTargeting('URL', window.location.pathname);
  16.    googletag.pubads().disableInitialLoad();
  17.     googletag.pubads().enableLazyLoad({
  18.     fetchMarginPercent: 100,  // Fetch slots within 5 viewports.
  19.     renderMarginPercent: 100,  // Render slots within 2 viewports.
  20.     mobileScaling: 2.0  // Double the above values on mobile.
  21.   });
  22.      googletag.enableServices();
  23.  });
  24.  
  25.  var aiNextSlotId = 1;
  26.  
  27.  function aiGenerateNextSlotName() {
  28.    var id = aiNextSlotId ++;
  29.    return 'ai-slot-' + id;
  30.  }
  31.    
  32. function aiLoadBlock(adUnitPath, size, unit) {
  33.   var slotName = aiGenerateNextSlotName();
  34.  
  35.   document.getElementById ("ai-block").id = slotName;
  36.   googletag.cmd.push(function() {
  37.   //console.log(unit);
  38.   if (unit == "LDBD"){
  39.   //console.log(unit);
  40.   var mapping = googletag.sizeMapping().
  41.   addSize([992, 0], [728, 90]). //desktop
  42.   addSize([768, 0], [728, 90]). //tablet
  43.   addSize([0, 0], [320, 50]). //other
  44.   build();
  45.   }
  46.   else if (unit == "TPBT"){
  47.   //console.log(unit);
  48.   var mapping = googletag.sizeMapping().
  49.   addSize([992, 0], [[970, 90], [970, 250], [728, 90]]). //desktop
  50.   addSize([768, 0], [728, 90]). //tablet
  51.   addSize([0, 0], [[320,50],[300,100]]). //other
  52.   build();
  53.   }
  54.   else if (unit == "DYNA"){
  55.   //console.log(unit);
  56.   var mapping = googletag.sizeMapping().
  57.   addSize([992, 0], [[728,90],[300,250],[336,280],[468,60], [300,600],[320,50],[300,100]]). //desktop
  58.   addSize([768, 0], [[728,90],[300,250],[336,280],[468,60], [300,600],[320,50],[300,100]]). //tablet
  59.   addSize([0, 0], [[300,250],[336,280], [300,600],[320,50],[300,100]]). //other
  60.   build();
  61.   }
  62.   else if (unit == "SIDE"){
  63.   //console.log(unit);
  64.   var mapping = googletag.sizeMapping().
  65.   addSize([0, 0], [[300,250],[336,280],[300,600],[320,50],[300,100]]).
  66.   build();
  67.   }
  68.    else if (unit == "FOOT"){
  69.   //console.log(unit);
  70.   var mapping = googletag.sizeMapping().
  71.   addSize([0, 0], [300,250]).
  72.   build();
  73.   }
  74.     var slot = googletag.defineSlot(adUnitPath, size, slotName).
  75.     defineSizeMapping(mapping).
  76.       addService(googletag.pubads());
  77.     googletag.display(slotName);
  78.     googletag.pubads().refresh([slot]);
  79.   });
  80. }
  81. </script>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top