百度MIP添加Google Adsense# 关于百度MIP页面正确的添加Google Adsense广告方法

#百度MIP添加Google Adsense# 关于百度MIP页面正确的添加Google Adsense广告方法

起因

突然想看看我在MIP页面添加(谷歌广告)Google Adsense是什么样子,直接复制Google 广告代码到MIP页面是不好使用的,而且MIP自带的Baidu-AD组件-并不能满足添加Google Adsense。
但是在GitHub发现MIP的项目可以自己写组件,看了开发文档,发现我并且没有写组件的能力,所以只有搜索看看有没有百度MIP页面添加Google Adsense的组件了,使用百度并且没有搜索到正确的,之后转战Google搜索。然后就转载了了这篇文章

Google Adsense网页广告的三种形式

1、手动展现自适应广告 -- 代码如下

    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <ins class="adsbygoogle"
    style="display:block"
    data-ad-client="ca-pub-1633908719521615"
    data-ad-slot="9083799012"
    data-ad-format="auto"
    data-full-width-responsive="true"></ins>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

2、自动展现自适应代码 -- 代码如下

    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-1633908719521615",
    enable_page_level_ads: true
    });
    </script>

3、AMP自动展现自适应代码 -- 代码如下

<!-- 以下代码在Header添加-->
    <script async custom-element="amp-auto-ads"
    src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js">
    </script>
<!-- 以下代码在内容部分添加-->
    <amp-auto-ads type="adsense"
    data-ad-client="ca-pub-1633908719521615">
    </amp-auto-ads>

MIP网页添加谷歌广告(Google Adsense)的具体方法教程

首先在MIP页面的引入第三方开发的MIP-Adsense.js组件

<!--引入 mip-adsense.js-->
<script src="https://c.mipcdn.com/static/v1/mip-adsense/mip-adsense.js"></script>

在适合的位置添加广告代码

<!--Google Adsense MIP 版代码-->
<mip-adsense ad-client="ca-pub-1633908719521615" ad-slot="9083799012" ad-format="auto"></mip-adsense>

注意!!!! -- 填写的为第一种形式的! 并且参数为你的Google Adsense参数

上面的为 Google Adsense 原版的广告代码,切记是不能够直接放置在页面中的,而是通过获取原版代码中的两个参数对应填写在 MIP 版代码中对应的位置。

参数解释

ad-client 说明:用户;必选项:是;类型:字符串
ad-slot 说明:位置;必选项:是;类型:字符串
ad-format 说明:格式;必选项:否;类型:字符串
ad-width 说明:宽度;必选项:否;类型:字符串
ad-height 说明:高度;必选项:否;类型:字符串

到这里就结束了,你打开MIP页面应该可以看的Google Adsense的广告。有问题请留言

转载至泪雪博客-有删改

原文链接:https://zhangzifan.com/mip-adsense.html