通过 HTTPS 加载广告代码

概览

确保安全地请求广告代码库脚本。这不仅可为用户提供更好的安全性,还可提高性能。由于 GPT 发出的广告请求始终使用 HTTPS,因此通过 HTTPS 从推荐的主机中加载库本身可确保浏览器只需为与广告投放相关的所有请求打开 1 个连接。

建议

请务必通过 HTTPS 网址加载广告代码脚本。

不正确
<script>
  var el = document.createElement('script');
  // Incorrect: potentially loading the ad tag over HTTP.
  var useSSL = 'https:' == document.location.protocol;
  el.src = (useSSL ? 'https:' : 'http:') + '//securepubads.g.doubleclick.net/tag/js/gpt.js';
  var node = document.getElementsByTagName('script')[0];
  node.parentNode.insertBefore(el, node);
</script>
正确
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>

更多信息

支持以下广告代码库脚本:

脚本
AdSense

pagead2.googlesyndication.com/pagead/js/adsbygoogle.js

pagead2.googlesyndication.com/pagead/show_ads.js

Google 发布商代码

googletagservices.com/tag/js/gpt.js

securepubads.g.doubleclick.net/tag/js/gpt.js

Google 发布商代码使用入门