Support » Plugin: GDPR » How to code which cookies to set

  • Unfortunately it is a bit tricky to make code adjustments work with the helper functions mentioned, so cookies are allowed/not-allowed based on consent.

    Since most probably have the Google Analytics, Adwords/adsense and Facebook cookies, maybe possible to make the guide show what exactly to do for these specific cookies, so a bit easier to set up?

    By the way, Google Analytics cookies etc are still allowed to be set without consent, as long as they do not collect personal data like the IP address etc. So not sure how/whick cookies to set to not block all statistics…

    • This topic was modified 2 years, 2 months ago by kmorgen.
Viewing 5 replies - 1 through 5 (of 5 total)
  • +1

    I have the problem that I can not configure the is_allowed_cookie since there is no way to detect the _ga cookie. In my browser it is present but neither by console putting is_allowed_cookie (‘_ ga’) it always detects false.

    How is it really implemented to detect the cookie and execute the code or not? I apply the information in the manual and it does not work …

    To make it work you have to wrap is_allowed_cookie within the code block that runs GA. So rather than inserting that snippet on it’s own like it is on the docs it runs within your existing GA code block.

    Here is mine as an example in my functions.php. Mine uses _utma rather than _ga, and I load mine into the footer, but I have changed it to _ga for you and you can change footer to header if you prefer:

    function google_analytics_tracking_code(){
    	if ( is_allowed_cookie( '_ga' ) ){
    	<script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    <?php }
    add_action('wp_footer', 'google_analytics_tracking_code');

    Note that in V2 there is an issue where deselecting the cookie group on the popup bar itself doesn’t remove the cookies. That hopefully will be looked into, but other than that it’s running for me as intended using the above.

    Hope that is of some use,


    • This reply was modified 2 years, 2 months ago by John Hogan.
    • This reply was modified 2 years, 2 months ago by John Hogan. Reason: Edited due to code formatting not setting correctly

    Hello John,

    my problem is that if I open google chrome and with analitycs activated and running in the console I put is_allowed_cookie (‘_ ga’) it always returns false. It is as if the browser itself did not detect _ga’s cookie ever. Then of course, if I always return false functions like the one you show me will not work. I’m trying it with Chrome, Safari, Firefox and the same thing happens to me … I see the cookie _ga in cookies but when I run in the browser console is_allowed_cookie (‘_ ga’) it returns false.

    At last I have already found out what happens!

    Let’s see how I explain it because this I think is wrong at the conceptual level.

    The problem is that when we configure third-party cookies, we mark that they are not activated as standard. The logical thing is that if someone accepts and agrees to the “I Agree” button, I thought that all cookies were activated as the user accepted.

    What happens now? That I have to leave activated the option of third-party cookies so that when they accept it activates. This confuses the user since it is activated and may think that they have already been installed.

    I think the logical thing is that if you accept it activates everything we have of cookies and then later if you want to deactivate it.

    do not?

    Plugin Author Fernando Claussen


    After I’m done fixing everything that our users are finding with v2 I’ll get started on a better/updated documentation

    My idea for third-party cookies was for cookies that you can’t disable with our functions. Vimeo and others, for example, place cookies to track where you stopped or video and so on. You can’t really block those with the functions without blocking the entire video, and if you have a video there, it is probably very important. So I added this option for you to link back to these type of services where a user might find instructions to opt out. If such instructions don’t exist, a link to the service privacy policy might be good enough.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to code which cookies to set’ is closed to new replies.