AMP Google AdSense

Ads are the most important thing for publishers and it is a must for AMP pages. Since installing the add-on, mobile traffic skyrocketed, reaching to desktop users. And this, decreased our ads income. So, ads for AMP should be implemented ASAP.
 
Upvote 0
Right now you can include amp ad tags in the ad_message_below template and they will show up on amp pages. If you want an ad above the fold right now you have to manually ad the ad_above_content template into the amp templates.
 
Here is the code:

Code:
<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
<amp-ad width="300"
      height="250"
      type="adsense"
      data-ad-client="ca-pub-XXXXXXXXXXX"
      data-ad-slot="XXXXXXXXXXX">
</amp-ad>
 
OK, now it works but this is against the adsense policy! There is an ad under every message!

Code:
<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
<amp-ad
layout="responsive"
width=300
height=250
      type="adsense"
      data-ad-client="ca-pub-"
      data-ad-slot="">
 </amp-ad>

We would like to add it according to Google Adsense policy. No more than 3 ads per page.
 
Last edited:
OK, now it works but this is against the adsense policy! There is an ad under every message!

Code:
<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
<amp-ad
layout="responsive"
width=300
height=250
      type="adsense"
      data-ad-client="ca-pub-"
      data-ad-slot="">
 </amp-ad>

We would like to add it according to Google Adsense policy. No more than 3 ads per page.

Code:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 2">
Ad Code
</xen:if>

<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 6">
Ad Code
</xen:if>

<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 10">
Ad Code
</xen:if>

<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 15">
Ad Code
</xen:if>

<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 19">
Ad Code
</xen:if>
 
Here is our code:

PHP:
<xen:hook name="ad_message_below" />


<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0">
<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
<amp-ad
layout="responsive"
width=300
height=250
      type="adsense"
      data-ad-client="ca-pub-1488242594986984"
      data-ad-slot="7815013752">
 </amp-ad>
</xen:if>

<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 3">
<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
<amp-ad
layout="responsive"
width=300
height=250
      type="adsense"
      data-ad-client="ca-pub-1488242594986984"
      data-ad-slot="7815013752">
 </amp-ad>
</xen:if>

<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 9">
<script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
<amp-ad
layout="responsive"
width=300
height=250
      type="adsense"
      data-ad-client="ca-pub-1488242594986984"
      data-ad-slot="7815013752">
 </amp-ad>
</xen:if>

e.g.: Youtuberlik Hakkında Tavsiyeler
 
Back
Top