Is there a setting on Google Analytics to suppress use of cookies for users who have not yet given consent

后端 未结 13 1263
深忆病人
深忆病人 2020-12-02 03:33

According to EU Article 5(3) of the E-Privacy Directive (a.k.a \'The Cookie Laws\'), web sites that target EU users have to gain opt-in consent from users before they set a

13条回答
  •  -上瘾入骨i
    2020-12-02 04:06

    Sorry for being late to answer but I was looking for the same thing recently until I found out a way myself. It may not be the right way to do it but it works. (only works on site in question does not opt-out of GA completely). I have tested for a few days to make sure.

    The way I have managed to do it is using a PHP cookie. First start off with adding the analyticstracking.php include...

    
    

    and in analyticstracking.php add the following...

    
    
    
    
    
    

    Before the user has consented to cookies Google Analytics won't work and once they have, the 'consent_cookie' will be saved and will allow GA to work but if the 'google' cookie is destroyed it will stop GA from working (Obviously).

    Like I said it may not be the right way but I have tried and tested and it does. Hope this helps somebody.

提交回复
热议问题