How to Create an AMP Adsense Unit on Blogger

Adsense AMP

MyBacklink86 - When new to AMP HTML, it's hard to place the right Adsense ad unit on the AMP blog.

And now Google has given an explanation about the placement of Adsense ad units for AMP HTML blog. And after I try, ad units can look great on all device sizes.

If you are still confused in placing an ad unit Adsense on AMP blog, please refer to this post to complete.

Usually the code of an Adsense ad unit will look like below :


<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

<ins class="adsbygoogle"
   style="display:inline-block;width:120px;height:600px"
   data-ad-client="ca-pub-1234567891234567"
   data-ad-slot="1234567890"></ins>
<script>

(adsbygoogle = window.adsbygoogle || []).push({});

</script>

The code marked above is the code needed for the amp ad unit.

For Top Display (Above The Fold)



The top-of-the-fold display is the screen display once the blog is open (the first view is visible before the screen is scrolled down). For ad units on this top view screen (such as an ad below the header), it is highly recommended to use a ad unit fixed-height 100px (the width of the ad will follow its width, while the height will remain 100px). That way, the ads that show up are ads with a height in the 100px range.

Please use the amp ad code as below



<amp-ad
layout="fixed-height"
height="100"
type="adsense"
data-ad-client="ca-pub-1234567891234567"
data-ad-slot="1234567890">
</amp-ad>

Use the data-ad-client and data-ad-slot of your Adsense ad units.

For On-Screen Display Ads On-Scroll (Below The Fold)



Below the fold is the screen that appears after the page is scrolled. Usually these ads are stored under posts or above and below comments.

For this ad it is recommended to use an ad unit with a height of 250px. Here I use layout="fixed-height" so the ads that appear are ads that are high in the 250px range.

Please use the code amp ad as below


<amp-ad
layout="fixed-height"
height="250"
type="adsense"
data-ad-client="ca-pub-1234567891234567"
data-ad-slot="1234567890">
</amp-ad>

Use the data-ad-client and data-ad-slot of your AdSense ad units.

And make sure you've installed js amp-ad below </head> .


<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>