Google Analytics(分析)上有一项设置,可禁止尚未获得同意的用户使用Cookie [英] Is there a setting on Google Analytics to suppress use of cookies for users who have not yet given consent

查看:287
本文介绍了Google Analytics(分析)上有一项设置,可禁止尚未获得同意的用户使用Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据欧盟电子隐私指令(又称Cookie法)第5条第(3)款,针对欧盟用户的网站必须在用户设置cookie之前获得用户的选择同意。

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 cookie.

请参阅 ICO指南

我想在我的网站上用 Google Analytics(分析)进行翻译。

I am trying to square this with Google Analytics on my web site.

我想象,Google Analytics(分析)可以在不需要使用Cookie的情况下,进行一定程度的分析数据收集。

I would imagine that Google Analytics (GA) can do a certain level of analytic data gathering without requiring the use of cookies.

但是,我在此处(在Google网站/设置面板上)找不到任何有关如何在页面请求期间将有关同意状态的信息转发回Google的信息。所以,我唯一的选择似乎是,如果用户没有明确同意,我不应该嵌入Google标签代码 。这似乎有点激烈。

However, I cannot find any info on this (on the Google sites/settings panels) about how to relay information about the 'state of consent' back to Google during a page request. So, my only option seems to be that I should not embed Google tag code at all if the user has not explicitly given consent. Which seems a bit drastic.

让我的服务器脚本在JavaScript代码中设置 hasConsentedToCookies = FALSE 标志,可以指示Google的服务

Letting my serverside script set a hasConsentedToCookies=FALSE flag in the JavaScript tags would allow me to instruct Google's services to run in a gracefully degraded fashion.

Google Analytics(分析)上是否有设置,禁止未获得同意的用户使用cookie

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

如果是,我可以在哪里找到相关信息?

If so, where can I find info on this?

推荐答案

Google Analytics有一组新的API来协助遵守Cookie选择停用规定。 这里是文档,这里是他们的帮助文档

Google Analytics has a new set of APIs to assist with compliance with a cookie opt-out. Here's the documentation, and here's their help docs.

欧盟Cookie规则(在成员国实施)是否要求被动网络分析跟踪需要选择性合规机制,存在一些歧义。如果你有任何问题,请咨询律师。

There has been some ambiguity as to whether the EU Cookie Regulations (as implemented in member countries) require that passive web analytics tracking requires opt-in mechanisms for compliance. If you're concerned one way or another, consult an attorney. Google is empowering you to make the decision as to how you want to proceed.

他们会为您提供实作详情,但是,一旦您决定了确定是否在Google Analytics(分析)中跟踪用户,如果答案是不跟踪,则在Google Analytics(分析)运行之前,您应将以下属性设置为true:

They'll leave implementation details to you, but, the idea is, once you've determined whether or not to track the user in Google Analytics, if the answer is to not track, you'd set the following property to true before Google Analytics runs:

window['ga-disable-UA-XXXXXX-Y'] = true;

其中UA-XXXXXX-Y是您Google Analytics(分析)中的帐户ID

Where UA-XXXXXX-Y is your account ID in Google Analytics

正如其他海报所述,Google Analytics(分析)依赖于Cookie。因此,您无法在没有Cookie的情况下进行任何跟踪。如果您确定不要为某人进行跟踪而进行跟踪,则需要实施以下操作:

As the other posters have noted, Google Analytics relies on cookies. So, you're not able to do any kind of tracking without cookies. If you've determined that someone is not to be cookied for tracking, you'll need to implement something like this:

if(doNotCookie()){
   window['ga-disable-UA-XXXXXX-Y'] = true;
}



选择启用



这首先需要加载Google Analytics(分析),因为这个属性需要在之前设置 Google Analytics(分析)运行,以防止跟踪从未发生,这意味着,对于opt跟踪方法,您可能需要实施一种机制,在首次访问时,Google Analytics(分析)在没有选择加入Cookie(明确允许Cookie偏好设置的Cookie)的情况下自动停用,然后,如果发生选择加入,重新运行Google Analytics(分析)。在后续的网页浏览中,所有内容都会顺利运行

Opt In

This does require a little bit of jujitsu for when you first load Google Analytics, since this property will need to be set before Google Analytics runs to prevent tracking from ever happening, which means, for an "opt in to tracking" approach, you'd probably need to implement a mechanism where, on first visit, Google Analytics is automatically disabled in the absence of an opt-in cookie (cookies that determine cookie preferences are explicitly allowed), and then, if an opt-in happens, re-runs Google Analytics. On subsequent pageviews, all would run smoothly.

可能类似于(伪代码):

Could look something like (pseudo-code):

if( hasOptedOut() || hasNotExpressedCookiePreferenceYet() ){ //functions you've defined elsewhere
     window['ga-disable-UA-XXXXXX-Y'] = true;
}
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXXX-Y']);
  _gaq.push(['_trackPageview']);


  function onOptIn(){ //have this run when/if they opt-in.
      window['ga-disable-UA-XXXXXX-Y'] = false;
      //...snip...
      //set a cookie to express that the user has opted-in to tracking, for future pageviews
      _gaq.push(['_trackPageview']); // now run the pageview that you 'missed'
   }



选择停用



使用此方法,您可以允许用户选择停用跟踪,这意味着您将使用Cookie设置 ga-disable -UA-XXXXXX-Y'属性和将来管理它的Cookie:

Opt Out

With this approach, you'd allow the user to opt-out of tracking, which would mean you'd use a cookie to set the ga-disable-UA-XXXXXX-Y' property and a cookie to manage it in the future:

if( hasOptedOut() ){ // function you've defined elsewhere 
     window['ga-disable-UA-XXXXXX-Y'] = true;
}

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXX-Y']);
  _gaq.push(['_trackPageview']);

这篇关于Google Analytics(分析)上有一项设置,可禁止尚未获得同意的用户使用Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆