删除Google Analytics Cookie和欧盟电子隐私法
On my site, if user refuses to use cookies (according to the EU e-privacy directive), I block tracking of Google Analytics using the JavaScript ,
在我的网站上,如果用户拒绝使用cookie(根据欧盟电子隐私指令),我会阻止使用JavaScript跟踪Google Analytics,
window['ga-disable-UA-XXXXXX-X'] = true;
With this command tracking is disabled and seems to work (if I surf on the site, Google Analytics doesn't see any activity).
使用此命令可以禁用跟踪并且似乎有效(如果我在网站上浏览,Google Analytics不会看到任何活动)。
But I notice that __utma
, __utmb
,.... cookies are still on my browser (in Chrome), so I tried to delete them with setcookie
function of php:
但是我注意到__utma,__ utmb,.... cookies仍然在我的浏览器上(在Chrome中),所以我尝试用php的setcookie函数删除它们:
foreach ($_COOKIE as $key => $value) {
setcookie($key, '', time()-1000,'/','.mydomain.com');
}
But without success! (I inserted this code after the GA monitoring JavaScript) GA cookies are ever on my browser.
但没有成功! (我在GA监控JavaScript之后插入了这段代码)GA cookie一直在我的浏览器上。
So, Can I delete GA cookies?
那么,我可以删除GA cookie吗?
Or Is enough blocking GA tracking for EU e-Privacy Directive?
或者是否足以阻止GA跟踪欧盟电子隐私指令?
1 个解决方案
#1
1
Yes, you can delete the cookies. You just have to match the exact Path
and Domain
parameters as the ones used in those cookies. You can use this code and replace the parameters with yours:
是的,您可以删除cookie。您只需要将精确的路径和域参数与这些cookie中使用的参数进行匹配。您可以使用此代码并将参数替换为您的参数:
function deleteCookie(name) {
document.cookie = name + '=; Path=/; Domain=.example.com; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
更多相关文章
- 如何使用AngularJS获取url参数
- 当开始使用数据-*时,无法识别AngularJS指令
- $ postLink的角度组件/指令运行得太早
- js 处理url中文参数 java端接收处理
- AngularJs location.path没有传递参数
- element.replaceWith在自定义指令的链接中仅在第一次调用时工作
- XGBoost中参数调优的完整指南(含Python-3.X代码)
- python传递列表作为函数参数
- Python学习之路:函数的非固定参数