How to add Google AdSense to your Blogger entries in AMP HTML?

3 minute read


It depends on the ad size you need to insert in a Blogger entry, for that I'm going to show some examples of the most used ad sizes in the AMP format.
AMP ad units can be adaptable or have a fixed size.
First:
We created a Google AdSense ad from the official site.
Next, it generates a code similar to the following.

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!—Ads Adsense -->
<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:250px"
     data-ad-client="ca-pub-2262852945838153"
     data-ad-slot="2276018923"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

From the code generated by Google AdSense, we will copy only the two codes that are marked yellow and replace it with the codes that are marked yellow of the 5 examples.

Ad sizes with better performance.

300 x 250 , 336 x 280 , 728 x 90 , 300 x 600 , 320 x 100

Example:


Choose any of the following AMP codes based on the ad size you need.

Fixed sizes:

Ad size 300 x 250

<amp-ad width="300" height="250"
      type="adsense"
      data-ad-client="ca-pub-2262852945838153"
      data-ad-slot="2276018923"
 </amp-ad>

Copy the code you need in an entry in HTML mode, replace the two codes that are marked in yellow by the two codes of your ad.

If you need to center the ad on one entry, you only have to increase the next rule.

<center>
Insert the ad code here in AMP.
</ center>

Matikan AdBlock

Agar blog Igniel tetap berjalan, matikan AdBlock atau masukkan blog ini ke dalam whitelist.
Terima kasih.