Google Analytics 上是否有设置禁止尚未同意的用户使用 cookie [英] Is there a setting on Google Analytics to suppress use of cookies for users who have not yet given consent

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

问题描述

根据欧盟电子隐私指令第 5(3) 条(又称Cookie 法"),面向欧盟用户的网站在设置 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 (GA) 可以在不要求使用 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?

推荐答案

EDIT (2019):以下答案早于 GDPR,可能需要修订.

Google Analytics 有一组新的 API 来帮助遵守 cookie 选择退出.这是文档,这是他们的帮助文档.

欧盟 Cookie 条例(在成员国实施)是否要求被动网络分析跟踪需要选择加入机制以确保合规性,这一点一直存在一些模棱两可的说法.如果您以某种方式担心,请咨询律师.Google 授权您决定如何继续.

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 运行之前为真:

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,您将无法进行任何类型的跟踪.如果您确定某人不会被 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 运行之前设置此属性以防止跟踪发生,这意味着,对于选择加入跟踪"方法,您可能需要实施一种机制,在第一次访问时,如果没有选择加入 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天全站免登陆