How do you render Google ad units in localhost?(如何在本地主机中呈现Google广告单元?)
问题描述
根据研究,2014年的前一个问题(Is Google adsense available for localhost?)建议添加:
data-adtest="on"
在测试和阅读comments之后,解决方案不再起作用。在广告单元中:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- responsive_ad -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-####"
data-ad-slot="######"
data-ad-format="auto"
data-adtest="on"
data-full-width-responsive="true">
</ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
在Chrome、Firefox和Safari上测试后,会呈现一个白框。在搜索之后,我无法在产品论坛或任何网站上找到任何解决方案。如何在本地主机中测试广告单元?
推荐答案
我也尝试了data-adtest="on"
方法,它对我也不起作用。我发现了两种不同的测试方法:
- 使用占位符,这是大多数Google Adense论坛条目建议的方式。 例如:https://productforums.google.com/forum/#!msg/adsense/RLeUEq6na-w/i93-TFVRiHUJ (我自己试过了,我对解决方案很满意)
- 使用您自己的(Dev)域此处解释:https://medium.com/@jeffersonlicet/testing-ads-on-localhost-300215b415d6(我无法自己尝试,因为我没有域)
如果您打开了开发人员控制台,您会看到出现403错误。这里进一步解释了该错误的原因:https://www.shoutmeloud.com/adsense-403-forbidden-error.html。长话短说:Adense Crawler拒绝本地主机。这就是为什么你看到的是空白而不是广告。
但如果有第三种方法,我也很高兴听到。
这篇关于如何在本地主机中呈现Google广告单元?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在本地主机中呈现Google广告单元?


基础教程推荐
- 在for循环中使用setTimeout 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 我什么时候应该在导入时使用方括号 2022-01-01
- 悬停时滑动输入并停留几秒钟 2022-01-01
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 动态更新多个选择框 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01