• First of all, congratulations to the creator for this fabulous plugin. I have a problem I do not understand how I should block a cookie until the user has given his consent.

    I can block or unblock the Google Analytics cookie. No problem, it works for me. I got the code here: https://gdpr-wp.com/knowledge-base/enabling-or-disabling-functionality-based-on-consent-and-cookies/

    But what about the other cookies ?? I use the following code but it doesn’t work. I got a mistake 500. I insert the code in the functions.php :

    add_action( 'wp_head', 'preferences' );
    function preferences() {
      if ( ! has_consent( 'Préférences' ) || ! is_allowed_cookie( '_AVESTA_ENVIRONMENT' ) )  }

    Please help me! Please!

    Thank you

Viewing 15 replies - 1 through 15 (of 43 total)
  • Christian

    (@visualframeworks)

    Hi,sorry for off topic.
    But how did you get this _ga to work?
    It wont work for me. Even with the code from gdpr’s website.

    • This reply was modified 6 years, 6 months ago by Christian.
    Thread Starter imloic

    (@imloic)

    First, i use the Google Analytics Dashboard for WP (GADWP) After open your fuctions.php and insert this code :

    // GDPR COOKIES
    // GDPR ANALYCTICS
    
    add_action( 'wp_head', 'my_google_opt_out' );
    function my_google_opt_out() {
        if ( is_allowed_cookie( '_ga' ) ) {
        ?>
        <script>
    		window['ga-disable-UA-XXXX'] = false;
    	</script>
    	
    	<?php
      }
    	else{
    ?>
    	<script>
    		window['ga-disable-UA-XXXX'] = true;
    	</script>
    <?php
    }
    }

    2 – Don’t forge to remplace XXXX with your UA code
    3 – In GDPR plugin -> Cookies used -> _ga,_gat,_gid,

    • This reply was modified 6 years, 6 months ago by imloic.
    • This reply was modified 6 years, 6 months ago by imloic.

    The window ga disabled did remove/add all 3(_ga,_gat,_gid) on my site.
    SO i think ga disable works for all of the google analytics cookies.

    • This reply was modified 6 years, 6 months ago by Willem Munts.
    • This reply was modified 6 years, 6 months ago by Willem Munts.
    Thread Starter imloic

    (@imloic)

    @thedarkeye

    Yep window ga disabled remove _ga,_gat,_gid

    What we want !

    @imloic

    you use google chrome? if yes, try to go to your cookies in the browser with F12 en then application then cookies on the left. And you can find the cookie gdpr privacy bar which value is 1. if you click once on it then press delete button. refresh the page and de privacy bar appears again on your site. Now if you accept all the cookies, included _ga. Then go back to the cookies and delete the gdpr privacy bar again. Refresh the page and now only accept the necessary cookie, so NOT _ga. Now my _ga does not go away.

    How is that with your site?

    grtz Willem

    Salut @imloic,
    Essaie sans les accents et sans majuscule pour has_consent( ‘Préférences’ )…

    Plugin Author Fernando Claussen

    (@fclaussen)

    For it to work with other cookies, you need to wrap the code that creates those.

    If you have a snippet of code from some other service or your own code, just wrap it with the is_allowed_cookie( ‘cookiename’ ) and it should do the trick.

    You don’t need to check for consents and cookies at the same time if you don’t want to.

    Thread Starter imloic

    (@imloic)

    @bonaldi

    Je crois que ?a change rien, si j’ai bien compris faut inclure le code de l’éditeur du cookie pour le bloquer

    @fclaussen
    You mean i have to find a code from the editor and wrap it with

     is_allowed_cookie( ‘cookiename’ ){
    
    //code from the editor in order to enable cookie
    
    }

    But it’s hard to find a code for each cookie ! Sometimes there is no code.
    How to do ?

    • This reply was modified 6 years, 6 months ago by imloic.
    Plugin Author Fernando Claussen

    (@fclaussen)

    There’s always code.
    You can google the name of the cookie and this will give you a hint to what the snippet looks like and where it might be.

    If this is coming from a plugin, there’s not much you can do besides changing the plugin code (not recommended).

    Thread Starter imloic

    (@imloic)

    All is clear now. Thanks man ! Great job !

    Thread Starter imloic

    (@imloic)

    @thedarkeye

    It’s true, but why delete gdpr privacy bar cookie ?

    If i accept Analytics _ga he will be enable. If i decline its will be disable. It’s simple and this what we need.

    @imloic

    i did read something about rectification or something, the right that the visitor can change his choice of cookies to accept, if he/she wants that.

    delete privacy bar cookie is just a fast way to show the bar again, but as far as i know, visitors need to have the right to change the cookies they accept or not.

    Thread Starter imloic

    (@imloic)

    @thedarkeye

    Yes you right but there no No HTTP response detected with Google Analytics once _ga is blocked.

    Try to enabled again : Page View request is OK

    I use Tag Assistant (By Google) with Chrome. And i think it’s OK

    Or maybe im totally wrong ??

    About gdpr-wp.com i saw Requiert cookie are not loaded with inspector tools (Application -> Cookie) Strange ! How do ?

    @imloic

    Strange, your cookie do not load in inspector?

    Thread Starter imloic

    (@imloic)

    @thedarkeye no its ok

Viewing 15 replies - 1 through 15 (of 43 total)
  • The topic ‘How to block cookies ? Other than _ga’ is closed to new replies.