google 着陆页分析代码和 cookie 法

google analytics code on landing page and cookie law

新的欧盟 cookie 法不允许页面在首次加载时设置 cookie,并且在用户执行任何操作之前,滚动被视为隐式接受

我不确定

ga('set', 'anonymizeIp', true); 

足以让 google 分析被视为非分析 cookie

如何在页面加载后激活 google 分析? 使用 jQuery 页面滚动进行监控?

GA 选择退出

您可以允许人们选择退出网络跟踪。它是通过cookie制作的 https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#optout

<a href="javascript:gaOptout()">Click here to opt-out of Google Analytics</a>

<script>
// Set to the same value as the web property used on the site
var gaProperty = 'UA-XXXX-Y';

// Disable tracking if the opt-out cookie exists.
var disableStr = 'ga-disable-' + gaProperty;
if (document.cookie.indexOf(disableStr + '=true') > -1) {
  window[disableStr] = true;
}

// Opt-out function
function gaOptout() {
  document.cookie = disableStr + '=true; expires=Thu, 31 Dec 2099 23:59:59 UTC; path=/';
  window[disableStr] = true;
}
</script>

确认 cookie 使用后按需加载跟踪

如果您想首先询问,如果用户同意使用跟踪cookie,那么您可以将GA 跟踪推迟到某个触发器。触发器可以是例如cookieBar.

如果您使用 jQuery,这对您来说应该是一个很好的解决方案: http://www.primebox.co.uk/projects/jquery-cookiebar/

http://cookiesdirective.com/