【问题标题】:google analytics code on landing page and cookie law [closed]登陆页面和 cookie 法上的谷歌分析代码 [关闭]
【发布时间】:2015-06-18 08:20:50
【问题描述】:

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

我不确定

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

足以让谷歌分析被视为非分析 cookie

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

【问题讨论】:

  • 我投票结束这个问题,因为它是关于欧盟法律和谷歌分析的,而不是严格的编程。
  • 你可能想试试webmasters.stackexchange.com
  • 我不确定,但要解决这个问题,可能需要在页面滚动时通过 javascript / jQuery 触发分析

标签: jquery google-analytics seo


【解决方案1】:

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 跟踪推迟到某个触发器。触发器可以是例如饼干吧。

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

或者

http://cookiesdirective.com/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-18
    • 1970-01-01
    • 2016-09-25
    • 1970-01-01
    • 1970-01-01
    • 2014-10-26
    • 1970-01-01
    相关资源
    最近更新 更多