You are here

function google_admanager_gpt_async_init in DFP Small Business (Google Ad Manager) 6.3

1 string reference to 'google_admanager_gpt_async_init'
gpt_async.inc in plugins/ad_providers/gpt_async.inc

File

plugins/ad_providers/gpt_async.inc, line 31

Code

function google_admanager_gpt_async_init($conf) {
  $script = <<<EOL
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
(function() {
  var gads = document.createElement('script');
  gads.async = true;
  gads.type = 'text/javascript';
  var useSSL = 'https:' == document.location.protocol;
  gads.src = (useSSL ? 'https:' : 'http:') + '//www.googletagservices.com/tag/js/gpt.js';
  var node =document.getElementsByTagName('script')[0];
  node.parentNode.insertBefore(gads, node);
})();
EOL;
  google_admanager_add_js($script, 'init');
  $script = <<<EOF
  googletag.pubads().enableSingleRequest();
  googletag.enableServices();
});
EOF;
  google_admanager_add_js('googletag.cmd.push(function() {', 'slot');
  google_admanager_add_js($script, 'slot');
}