[Resolved] Adding google page level ads

Home Forums Support Adding google page level ads

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #444811
    Cristo Rey

    I want to install Google page level ads on my site. These are different from the usual Google Adsense ads that I already use.

    Here are the instructions they give:

    Place this ad code in the <head> tag (or at the top of the <body>) of the pages where you want to show the ads. It’s the same ad code for every page and site, and you won’t need to change it even if you adjust your Page-level ads settings.

    Do I need a plug in to do this or is there an easier way? Can I just use custom CSS?

    GeneratePress 2.0
    #444926
    Leo
    Staff
    Customer Support

    Hi there,

    According to the instruction, wp_head and before header hook should both work: https://docs.generatepress.com/article/hooks-overview/

    #444937
    Cristo Rey

    Thanks, Leo…I assume I add it in GP Hooks where it says “wp_head”, is that correct?

    #444944
    Leo
    Staff
    Customer Support
    #444947
    Cristo Rey

    One more thing….do I click “execute PHP” or not?

    #444950
    Leo
    Staff
    Customer Support

    Depends the code is PHP or not 🙂

    #444962
    Cristo Rey

    This is the code…not php is it? I don’t really know what php looks like, believe it or not.

    <script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: “ca-pub-1347297678313627”,
    enable_page_level_ads: true
    });
    </script>

    #444972
    Cristo Rey

    Leo here is what I have now in GP Hooks (one for Google analytics and the new google adsense I just added:

    define( ‘GENERATE_HOOKS_DISALLOW_PHP’, true );

    <!– Clickx Analytics –> <script type=”text/javascript”>!function(e,n,o,t){var r=n.createElement(o);r.src=t+”?time=”+(new Date).getTime(),r.async=!0,r.onload=function(){ClickxTracker.init({twId:”EaD3myHiTSw”, apiUrl:”https://app.clickx.io&#8221;})},r.onerror=function(){console.log(“Error”)},n.getElementsByTagName(“head”)[0].appendChild(r)}(window,document,”script”,”https://app.clickx.io/clickx-tracker.js&#8221;);</script><noscript><p></p></noscript><!– End Clickx Analytics –>

    <script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: “ca-pub-1347297678313627”,
    enable_page_level_ads: true
    });
    </script>

    #445030
    Leo
    Staff
    Customer Support

    That’s not PHP so you don’t need to check the box 🙂

    #445110
    Cristo Rey

    Thanks.

    #445186
    Cristo Rey

    Well, Leo I did something wrong. Marked this as resolved, but then when I look at my site in real time it has the message

    define( ‘GENERATE_HOOKS_DISALLOW_PHP’, true ); shown at the top of each page, so don’t know what I did wrong. Here is what I have in GP Hooks:

    define( ‘GENERATE_HOOKS_DISALLOW_PHP’, true );

    <!– Clickx Analytics –> <script type=”text/javascript”>!function(e,n,o,t){var r=n.createElement(o);r.src=t+”?time=”+(new Date).getTime(),r.async=!0,r.onload=function(){ClickxTracker.init({twId:”EaD3myHiTSw”, apiUrl:”https://app.clickx.io&#8221;})},r.onerror=function(){console.log(“Error”)},n.getElementsByTagName(“head”)[0].appendChild(r)}(window,document,”script”,”https://app.clickx.io/clickx-tracker.js&#8221;);</script><noscript><p></p></noscript><!– End Clickx Analytics –>

    <script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
    <script>
    (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: “ca-pub-1347297678313627”,
    enable_page_level_ads: true
    });
    </script>

    Not sure what I did wrong.

    #445216
    Leo
    Staff
    Customer Support

    This shouldn’t be added in hooks: define( ‘GENERATE_HOOKS_DISALLOW_PHP’, true );

    See the instruction here: https://docs.generatepress.com/article/disallow-php-execution/

    #445260
    Cristo Rey

    Thanks, Leo. I had it in there before but not sure why.

    #445350
    Leo
    Staff
    Customer Support
Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.