Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #16920
    raffdes
    Participant

    Hello, can you give me an example of how it applied the blocking script?
    I’m interested to block preventively Google Analitycs and Google Adsense.
    Thanks!

    Please complete the instruction:

    if ( function_exists(‘cn_cookies_accepted’) && cn_cookies_accepted() ) {
    // Your third-party non functional code here
    }

    #16995
    Arthh11
    Participant

    Hi raffdes,

    I had the same problem than you and I found something on the support blog of the plugin.
    I was looking for blocking Google Analytics cookies before user consentement.

    You can try that (I did and it worked) :

    <?php
    if ( function_exists('cn_cookies_accepted') && cn_cookies_accepted() ) { ?>
    <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    
      ga('create', 'UA-69175630-1', 'auto');
      ga('send', 'pageview');
    </script>
    <?php } ?>

    I had a Google Analytics plugin but with that code, I desactivated it.

    Hope it’ll help you.

    Arthh11

    #25910
    hmqasim
    Participant

    Dear Arthh11,

    It worked perfectly. Please confirm that before each script (Adsense Ads) in my case, I need to put it inside this php function? Right?

    #26065
    esseem
    Participant

    Uhh, Id suggest one modification to the above: Where the example code says

    ga('create', 'UA-69175630-1', 'auto');

    It should read

    ga('create', 'PASTE YOUR GA PROPERTY ID HERE, E.G., UA-XXXXX-Y', 'auto');

    Otherwise, the script works well for me, thanks for posting it!

    #26112
    pixo
    Participant

    Hi,

    i have an strange issue.
    Plugin installed, google code with my id inserted.. that works!
    When i press no, i don’t want cookies, then it is disabled on all pages but not on the page where i pressed no.

    Checked with ghostery, cleared cache multiple times.
    Tested on 2 pages, always the same bug.

    Any ideas? Or do i missed any button?

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