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;';
}

更多相关文章

  1. 如何使用AngularJS获取url参数
  2. 当开始使用数据-*时,无法识别AngularJS指令
  3. $ postLink的角度组件/指令运行得太早
  4. js 处理url中文参数 java端接收处理
  5. AngularJs location.path没有传递参数
  6. element.replaceWith在自定义指令的链接中仅在第一次调用时工作
  7. XGBoost中参数调优的完整指南(含Python-3.X代码)
  8. python传递列表作为函数参数
  9. Python学习之路:函数的非固定参数

随机推荐

  1. 当鼠标悬停在顶部的对象上时,SVG悬停被取
  2. JavaScript动态显示时间
  3. JS 的 new 到底是干什么的
  4. HTML5绘图之Canvas标签 绘制坐标轴
  5. java 如何获取动态网页内容,返回字符串
  6. 我应该如何显示包含XML数据源的表?
  7. JavaScript系列----面向对象的JavaScript
  8. 在javascript中过滤对象对象(过滤还是减少
  9. 将div停靠在窗口左侧并再次单击原始位置
  10. 如何使用django从静态文件加载静态文件?