How to add Google AdSense in a Blogger Widget in AMP HTML?
3 minute read
First, copy and paste the following code between the <head> </ head> tags of the AMP HTML code. (the templates that are on this website already have the script, so you do not need to enter this procedure)
<script async='async' custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
Create customizable ad units compatible with AMP.
Adaptive AMP ad units must be created manually by following these steps.
1. Create a customizable ad unit in your AdSense account.
2. Look for the following data in the ad code of the adaptive block that you created in step 1 and write them down.
The publisher ID (data-ad-client), for example, ca-pub-1234567891234567
The ID of the ad unit (data-ad-slot), for example, 1234567890
You must copy the ad code in AMP and then go to Design, then the instructions:
One click on Design.
Open "Add a gadget"
Look for the Gadget that says "HTML / Javascript" open it.
Depending on where you need to place the gadget with the Google AdSense ad in AMP, choose any of the following codes:
Remember to replace the two codes that are marked in yellow by the two corresponding codes in your ad that are in your Google AdSense account.
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>
Ad size 728 x 90
<amp-ad width="728" height="90"
type="adsense"
data-ad-client="ca-pub-2262852945838153"
data-ad-slot="2276018923"
</amp-ad>
If you need to center the ad, you will only have to increase the next rule.
<center>
Insert the ad code here in AMP
</ center>
Any question do not hesitate to write in Comments.
Post a Comment