[Support request] Can’t Get AMP Auto Ads To Work … HELP Please ;-)

Home Forums Support [Support request] Can’t Get AMP Auto Ads To Work … HELP Please ;-)

Home Forums Support Can’t Get AMP Auto Ads To Work … HELP Please ;-)

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1494626
    Patrick

    I’ve added this code to Hook wp-head:

    <script data-ad-client="ca-pub-XXXXXXXXXX" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <script async custom-element="amp-auto-ads" src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js"></script>

    … and, I’ve added this code to Hook wp-body-open:

    <amp-auto-ads type="adsense"
            data-ad-client="ca-pub-XXXXXXXXXX">
    </amp-auto-ads>

    However, I still get no ads for the amp version of pages.

    Here is an example:

    AMP Version Of Page

    Any suggestions? Thanks πŸ˜‰

    #1494634
    Leo
    Staff
    Customer Support

    Hi there,

    Can you first confirm that you are using the AMP for GP plugin?
    https://github.com/tomusborne/amp-for-generatepress

    It should work with the official AMP plugin:
    https://en-ca.wordpress.org/plugins/amp/

    Let me know πŸ™‚

    #1494637
    Patrick

    Yes, it is installed and activated.

    #1494710
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    I’m seeing ads on that page: https://www.screencast.com/t/L6cYBY46P

    #1494712
    Patrick

    I just now placed a manual ad below the header but am still not getting any auto ads. Are you seeing just the one below the header or more than one ad per page? Thanks πŸ˜‰

    #1494780
    Elvin
    Staff
    Customer Support

    Hi,

    Are you seeing just the one below the header or more than one ad per page?

    I’m only seeing this. https://share.getcloudapp.com/E0urjWKA

    Yes. Just the one below the header.

    #1495793
    Patrick

    Still not resolved. It appears other plugin users are having similar issues. Should I try a different hook location?

    #1496150
    Tom
    Lead Developer
    Lead Developer

    What hook location are you using?

    The theme itself doesn’t control this – once the necessary scripts are added in the correct location, it’s 100% up to the ad provider to place them.

    #1496160
    Patrick

    Hook wp-head and Hook wp-body-open for the auto ads. (not working)

    Hook wp-head and Hook generate_after_header for the manual ad. (working)

    Since the manual is working and auto is not, it leads me to believe that there is something wrong with the placement of the wp-body-open for the auto ads. A few other users had the same issue in the forums, but I don’t want to use another plugin to make it work if I don’t have to.

    #1497359
    Tom
    Lead Developer
    Lead Developer

    wp_body_open should be placed directly inside the <body> element, which it is here: https://github.com/tomusborne/generatepress/blob/3.0.2/header.php#L27

    Do any of the plugins work?

    #1497385
    Patrick

    Yes, the plugins are working.

    #1497405
    Patrick

    Using Ad Inserter, everything works fine. However, I should not have to use the additional plugin … the issue is with GeneratePress or the GP Premium plugin. Others have had the exact same issue, not just me.

    See here:

    Add Adsense Auto ad code for AMP pages

    #1497644
    Tom
    Lead Developer
    Lead Developer

    Have you tried what was mentioned here?: https://generatepress.com/forums/topic/add-adsense-auto-ad-code-for-amp-pages/#post-1386008

    I’m not sure how the theme could be interfering with the code – it’s just HTML being added to the page. You can bypass the theme completely with some functions if you’d like:

    add_action( 'wp_head', function() {
        ?>
        <script data-ad-client="ca-pub-XXXXXXXXXX" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
        <script async custom-element="amp-auto-ads" src="https://cdn.ampproject.org/v0/amp-auto-ads-0.1.js"></script>
        <?php
    } );
    
    add_action( 'wp_body_open', function() {
        ?>
        <amp-auto-ads type="adsense"
            data-ad-client="ca-pub-XXXXXXXXXX">
        </amp-auto-ads>
        <?php
    } );

    That takes the theme completely out of the equation.

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