• Hi everyone, I’ve being banging my head against walls since GDPR came out.

    I haven’t been able to find a plugin good looking and easy to make my website GDPR compliant.

    Cookie notice seems to be easy and good looking, (or may be I’m writing <head> code wrong).

    The problem is that in Italy analytical cookies (suck as GA) should be activated only after user acceptance. Well, Cookie notice has a section saying exactly that.

    That’s the code I wrote inside HEAD section (obviously changing UA id to mine):

    
    <!-- Google Analytics -->
    <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','https://www.google-analytics.com/analytics.js','ga');
    
    ga('create', 'UA-XXXXX-Y', 'auto');
    ga('send', 'pageview');
    </script>
    <!-- End Google Analytics -->
    

    Now, when I load my page (purged from cache and cookie, I get only cookie “lwpcngStatus” set to 1 (accepted) but no __ga cookies.

    Where am I doing wrong?

    Thanks in advance,
    Francesco

Viewing 2 replies - 1 through 2 (of 2 total)
  • Ciao Francesco,
    ho affrontato anch’io il problema e per bloccare gli script in Cookie Notice uso una tecnica diversa che pare funzionare. Lascio completamente vuota la sezione di blocco script del plugin (che poi non è un blocco ma un’autorizzazione) e edito invece il codice delle pagine in questo modo:

    <?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-XXXXX-Y’, ‘auto’);
    ga(‘require’, ‘displayfeatures’);
    ga(‘send’, ‘pageview’);
    </script>
    <?php endif ?>

    Questo dovrebbe bloccare GA finchè l’utente non accetta il banner, ovviamente imposto il reload della pagina in Cookie Notice.

    Un approccio più raffinato (ma non mi è ancora chiaro se GDPR compliant o no) potrebbe essere di usare:

    <?php if ( function_exists(‘cn_cookies_accepted’) && cn_cookies_accepted() ): ?>
    script GA normale

    <?php else: ?>
    script GA anonimizzato

    <?php endif ?>

    Ciao,
    Riccardo

    • This reply was modified 5 years, 8 months ago by riccarbi.
    • This reply was modified 5 years, 8 months ago by riccarbi.
    Thread Starter franzkekko

    (@franzkekko)

    Ciao Riccardo ti ringrazio infinitamente, provo il tuo metodo e ti faccio sapere!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Analytics __ga TAG doesn’t get injected after click on “Accept”’ is closed to new replies.