Google DFP异步加载Adsense广告 进入DFP后先进入广 - Assbbs

Google DFP异步加载Adsense广告 进入DFP后先进入广告资源,新建广告单元,展示位置什么的可以不用设置,那个主要是为了方便管理的,然后新建一个订单,再在订单里新建一个订单项,订单项包含你建好的广告单元,类型建议选为赞助,这里功能非常多,我也没仔细研究 建好订单项后,添加广告,把你的adsense代码添加进去,然后把订单启用,回到广告资源,选择生…

Google DFP异步加载Adsense广告 进入DFP后先进入广告资源,新建广告单元,展示位置什么的可以不用设置,那个主要是为了方便管理的,然后新建一个订单,再在订单里新建一个订单项,订单项包含你建好的广告单元,类型建议选为赞助,这里功能非常多,我也没仔细研究 建好订单项后,添加广告,把你的adsense代码添加进去,然后把订单启用,回到广告资源,选择生成代码,把你的广告单元都包含了,选择异步模式 代码添加方式如下,在主题的head里加入广告单元定义  <script type=& 39;text/javascript& 39;> var googletag = googletag || {}; googletag.cmd = googletag.cmd ||  ; </script> <script type=& 39;text/javascript& 39;> googletag.cmd.push function  { googletag.defineSlot & 39;/xxxxxxx/侧边栏广告位& 39;,  200, 200 , & 39;div-gpt-ad-xxxxxxxxxxxxxxx-0& 39; .addService googletag.pubads ; googletag.pubads .enableSingleRequest ; googletag.enableServices ; } ; </script> 然后在你需要显示广告的地方插入广告单元标签 <!-- 侧边栏广告 --> <div id=& 39;div-gpt-ad-xxxxxxxxxx-0& 39; style=& 39;width:200px; height:200px;& 39;> <script type=& 39;text/javascript& 39;> googletag.cmd.push function  { googletag.display & 39;div-gpt-ad-xxxxxxxxxxxx-0& 39; ; } ; </script> </div> 最后再在footer里加入gtp.js的载入  <script type=& 39;text/javascript& 39;> function  { var gads = document.createElement & 39;script& 39; ; gads.async = true; gads.type = & 39;text/javascript& 39;; var useSSL = & 39;https:& 39; == document.location.protocol; gads.src =  useSSL ? & 39;https:& 39; : & 39;http:& 39;  +  & 39;//www.googletagservices.com/tag/js/gpt.js& 39;; var node = document.getElementsByTagName & 39;script& 39; 0 ; node.parentNode.insertBefore gads, node ; } ; </script> 参考自:http://xfeng.me/dfp-asyncronous-load-adsense/