如何使用preg_match自动将常规Google AdSense广告转换为响应广告
How to convert a regular Google AdSense Ad in a responsive ad automatically using preg_match?
- WordPress主题选项面板
- 一个文本区域字段,用户在其中输入其无响应的AdSense代码
我需要,如果用户输入一个非响应的adsense代码,该代码将转换为响应代码如下:
无扩展代码:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- non responsive ads -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-12345"
data-ad-slot="xxxxxxxxxxxxxx"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
上述代码需要在中转换
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-12345"
data-ad-slot="xxxxxxxxxxxxxx"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
我想这项工作可以用preg_match
完成,但怎么做呢?
谢谢。
你不能那样做(据我所知)。
该(无响应)单元配置存储在谷歌服务器上:
{
"status": "ACTIVE",
"kind": "adsense#adUnit",
"code": "xxxxxxxxxxxxxx",
"name": "non responsive ads",
"savedStyleId": "qwertzuiopšđžasdfghjklyxcvbnmqwerfvbgtzhnmjgbvfredcxsw",
"contentAdsSettings": {
"type": "TEXT_IMAGE",
"backupOption": {
"type": "BLANK"
},
"size": "SIZE_728_90"
},
"id": "ca-pub-12345:xxxxxxxxxxxxxx"
}
pagead2.googlesyndication.com会将data-ad-slot="xxxxxxxxxxxxxx"
广告请求视为对SIZE_728_90
格式的请求,并且你不能"随时"更改这一点——如果你需要另一个size
,你需要创建另一个广告单元。
即使你会这样做,而且看起来"有效",这仍然违反了AdSense政策,这将对你网站上所有涉及的AdSense账户和广告服务构成风险。(因为"转换"后的代码会使你产生一定百分比的无效广告印象和/或糟糕的请求。)
AdSense广告代码的修改
https://support.google.com/adsense/answer/1354736?hl=en
创建响应式广告单元
https://support.google.com/adsense/answer/3543893?hl=en
相关文章:
- 如何在Google柱状图中动态添加行/列
- Google/html5语音识别JavaScript SDK Chrome网络工具包SpeechRecognition
- 使用Google Visualization动态调用构造函数
- Firebase2(Firebase.google.com)推送通知-从外部管理
- 是否可以控制获取哪些Google地图脚本(JavaScript API)
- Google Adsense多次加载脚本
- Google AdSense:将背景颜色更改为透明
- URL中用户@的几个请求导致“;违反政策通知;来自Google AdSense
- 如何禁用基于布尔值的Google AdSense脚本
- Orbit Slider jQuery and Google Adsense
- Google AdSense 代码未在 asp.net 中执行
- 当登录是使用 JSON 时,如何让 Google Adsense 访问登录区域中的页面
- 内容安全策略可以与Google Analytics和AdSense兼容吗
- 如何使用preg_match自动将常规Google AdSense广告转换为响应广告
- cakePHP and Google AdSense
- 学习和理解Google AdSense在幕后是如何工作的
- Google Adsense在页面上破坏JavaScript:不安全的JavaScript试图访问带有URL的框架
- 仅向搜索引擎访问者显示Google AdSense广告
- 使用html javascript向搜索引擎流量显示Google AdSense广告
- 如何刷新 Google AdSense 内容