我们不允许对 AdSense 代码进行某些改动。了解可接受的广告代码修改以及植入代码时应避免的事项。
我们的计划政策不允许通过修改 AdSense 代码人为提升广告效果或损害广告客户的转化效果。您的发布商账号提供了多种广告代码生成选项,可以帮助您创建适合您网站的广告布局。
一般来说,我们建议您复制并粘贴广告代码。但我们也能理解,有时候为了提供理想的用户体验难免需要进行一些修改。
需避免采用的技术
以下是一些您需要避免采用的技术:
- 在任何时候均隐藏广告单元(例如:
display:none
),除非您要植入的是自适应广告单元。 - 植入的 AdSense 广告代码会造成广告遮盖内容或内容遮盖广告。
- 在移动网站或自适应设计网站上放置的广告单元会造成内容与广告相互重叠。
- 利用隐藏关键字、IFRAME 或其他任何方式操纵广告定位。
- 通过电子邮件或软件散播广告。
- 操纵广告投放或展示,使其以不适当的方式吸引用户注意(例如,以滑入屏幕的方式展示广告或缩放广告的大小)。
- 在用户于移动网页上执行拖动操作时触发广告点击。
可接受的修改
以下是一些可以接受的修改:
A/B 测试
利用 AdSense 实验,您可以比较不同广告类型和/或文字广告样式设置在广告单元中的效果。实验可以帮助您就如何配置广告单元做出明智决策,并有助于增加您的收入。详细了解实验。
如果您需要对 A/B 测试进行更多控制,请参考以下代码段:
- 同步广告代码:
<script type="text/javascript">
var random_number = Math.random();
google_ad_client = "ca-publisher-id";
google_ad_width = 728;
google_ad_height = 90;
if (random_number < .5){
google_ad_slot = "1234567890";
} else {
google_ad_slot = "2345678901";
}
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script> - 异步广告代码:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-publisher-id" crossorigin="anonymous"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-publisher-id">
</ins>
<script>
if (Math.random() < .5) {
mySlotId = '1234567890';
} else {
mySlotId = '2345678901';
}
(adsbygoogle = window.adsbygoogle || []).push({
params: { google_ad_slot: mySlotId }
});
</script>
动态设置自定义渠道
- 同步广告代码:
<script type="text/javascript">
var channel_condition = object.booleanMethod();
google_ad_client = "ca-publisher-id";
google_ad_slot = "1234567890";
google_ad_width = 728;
google_ad_height = 90;
if (channel_condition){
google_ad_channel = "123457789";
} else {
google_ad_channel = "263477489";
}
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script> - 异步广告代码:
<script async src="http://pagead2.googlesyndication.com/pagead/adsbygoogle.js?client=ca-publisher-id" crossorigin="anonymous">
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-publisher-id"
data-ad-slot="1234567890">
</ins>
<script>
channel_condition = object.booleanMethod();
if (channel_condition) {
my_google_ad_channel = '123457789';
}
else {
my_google_ad_channel = '263477489';
}
(adsbygoogle = window.adsbygoogle || []).push({
params: { google_ad_channel: my_google_ad_channel}
});
</script>
广告代码精简
- 同步广告代码:
<script type="text/javascript">
google_ad_client = "ca-publisher-id";
google_ad_slot = "1234567890";
google_ad_width = 728;google_ad_height = 90;
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script> - 异步广告代码:
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-publisher-id" crossorigin="anonymous""></script>
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-publisher-id"
data-ad-slot="1234567890"></ins>
<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>
要详细了解您可以对 AdSense 搜索广告代码进行哪些改动,请参阅 AdSense 搜索广告政策。