Support » Plugin: AMP » Ads not showing

  • Resolved satheeshrajv

    (@satheeshrajv)


    Hi,

    In my amp page ads are not showing. I’m using paired mode.

    Note: The AMP page will load properly only in mobile not in desktop. So please check it in mobile version.

    Regards,
    Satheeshraj V

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Pascal Birchler

    (@swissspidy)

    Hi @satheeshrajv

    Does your theme have some kind of separate mobile version then? Because that totally can mess with AMP validation, which might also be a problem causing the main issues you are having in https://wordpress.org/support/topic/issue-in-font-for-paired-mode/.

    First of all, page-level ads (enable_page_level_ads) are deprecated in AdSense. You should use AdSense Auto Ads instead. You can use this plugin to use Auto Ads with AMP: https://gist.github.com/westonruter/a41573b932e24810b09949136b9a8445

    Besides that, regular AdSense ads need to be declared a bit differently for AMP as well.

    Let’s take this example ad as it exists on your site multiple times:

    <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>

    For AMP, this will need to be replaced by this:

    <amp-ad width="100vw" height=320
      type="adsense"
      data-ad-client="ca-pub-1234567891234567"
      data-ad-slot="1234567890"
      data-auto-format="rspv"
      data-full-width>
        <div overflow></div>
    </amp-ad>

    In your theme, you can do something like this to use both versions, depending on whether you are looking at the AMP version or not:

    <?php if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) : ?>AMP ADSENSE CODE<?php else : ?>REGULAR ADSENSE CODE<?php endif; ?>

    For more information, please check out the AdSense documentation:

    https://support.google.com/adsense/answer/7183212?hl=en
    https://support.google.com/adsense/answer/9011465

    PS. Please note that on your regular non-AMP website you seem to be using AdSense incorrectly by loading adsbygoogle.js multiple times instead of just once.

    Hi Pascal,

    I tried to implement most of your suggestion and now ads are displaying properly. One thing that I need a clarification is about “enable_page_level_ads”. You have mentioned that it is deprecated but I’m able to see that in my adsense account.Is it really deprecated or we can use it.

    Regards,
    Satheeshraj V

    Plugin Author Pascal Birchler

    (@swissspidy)

    @satheeshrajv Good question! Deprecated means you can continue using them for the time being, but there won’t be any further enhancements to the feature. Your existing settings should have already been migrated over to Auto ads.

    Auto Ads offer some new opportunities like new ad formats and advanced URL settings. You can learn more about it here: https://support.google.com/adsense/answer/7627389?hl=en

    dhaval d

    (@dhavaldonga)

    Hi Pascal,

    I have added google ads in my website but when i open my blog with amp the ads are not showing. When i have check in google amp the error seems to be caused by a script for adsense http://prntscr.com/nx5mxy . I am not very familiar with this issue so please let me know proper solution for this.

    • This reply was modified 5 months ago by dhaval d.
    Plugin Author albertomedina

    (@albertomedina)

    @classicus Please open a separate topic in the forum to address your issue.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.