如何从动态 IP 地址中排除 Google Analytics 中的流量? [英] How to exclude traffic in Google Analytics from Dynamic IP addresses?

查看:31
本文介绍了如何从动态 IP 地址中排除 Google Analytics 中的流量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google 对异常流量的检测很好.但它是如何处理动态 IP 地址的?

Google's detection of Unusual traffic is nice. But how is it handling Dynamic IP addresses?

例如,我没有 IP 范围,我的 ISP 提供动态 IP,它可能会在我的路由器每次重新启动时发生变化,并且每天都在变化.所以在这里,当我获得一些 IP 地址时,我会看到没有验证码的通知.几次重新启动后,我似乎获得了一个未被阻止的 IP!

For example,I do not have ranges of IPs and my ISP provides Dynamic IP which may change everytime my router reboots and it changes everyday. So here, when I get some IP address I see notification w/o captcha. After several reboots I seem to get an IP which was not blocked!

如何在 Google Analytics 中解决此类问题.我也很清楚如何从单个 IP 和 IP 范围中排除流量,但我不知道如何阻止 IP 每天都在变化的内部流量?

How to solve this type of issues in Google Analytics. Also I know very well how to exclude traffic from single IP and with ranges of IPs but I do not know how to block internal traffic whose IPs changes everyday?

推荐答案

这个问题的许多流行答案都存在问题...

  • 即使您有幸找到了 IP 范围,如果您在咖啡店或酒店工作呢?
  • 检查主机名可以消除来自开发环境的点击,但如果我正在调试实时站点怎么办?
  • 编辑服务器配置很烦人/高级,多个域变得复杂.
  • 选择退出扩展程序要么阻止所有网站上的点击,要么完全不点击,具体取决于您询问的对象.

所以,我将其他几种解决方案组合成对我有用的东西......

  • 无论我走到哪里它都跟着我
  • 它适用于开发环境和实时/公共域
  • 它只会影响我和我正在开发的网站
  • 一键开启/关闭
  • 很容易验证它确实没有向分析发送任何数据
  • 整个团队都可以使用它

我始终在我的机器上为我管理的域设置一个开发者 cookie".此 cookie 具有特定于我的唯一值.然后,在向 Google Analytics(分析)发送任何数据之前,我只需在脚本中检查此 cookie.

I keep a "developer cookie" set on my machine at all times just for the domains that I manage. This cookie has a unique value that is specific to me. Then I simply check for this cookie in my scripts before sending any data to Analytics.

我如何将代码放入页面的示例...

Examples of how I put the code into my pages...

JavaScript

if (window.location.host==="mydomain.com" || window.location.host==="www.mydomain.com") {
   if (document.cookie.indexOf("COOKIENAME=COOKIEVALUE") === -1) {
      // Insert Analytics Code Here
   }
}

PHP

if ($_SERVER['HTTP_HOST']==="mydomain.com" || $_SERVER['HTTP_HOST']==="www.mydomain.com") {
   if (@$_COOKIE["COOKIENAME"] !== "COOKIEVALUE") {
      // Insert Analytics Code Here
   }
}

验证主机名称是否等于我的实时站点的域(mydomain.com")可确保任何访问者在从localhost"或beta.mydomain"等测试域查看时永远不会发送分析数据.com".在上面的示例中,www.mydomain.com"和mydomain.com"是我希望记录访问的两个有效域.

Verifying that the HOST name equals the domain of my live site ("mydomain.com") ensures that the analytics data will never be sent by ANY visitor while viewing from a test domain such as "localhost" or "beta.mydomain.com". In the examples above, "www.mydomain.com" and "mydomain.com" are the two valid domains where I DO want visits to be recorded.

除非找到具有匹配值的开发者 cookie,否则实时站点会按预期将数据发送到分析.如果它发现在我的设备上设置了唯一的 cookie,那么我的访问将不会计入我在 Google Analytics(或我可能决定使用的任何其他分析工具)中的总数.

The live site sends data to analytics as expected UNLESS a developer cookie is found with matching values. If it finds that unique cookie set on my device, then my visit will not count towards my totals in Google Analytics (or whatever other analytics tool I might decide to use one day).

但是当我的 cookie 被清除时会发生什么?如何在后台设置开发者 cookie"?我为此创建了自己的浏览器扩展...https://chrome.google.com/webstore/detail/lknhpplgahpbindnnocglcjonpahfikn

But what happens when my cookies get cleared? How do I keep the "developer cookie" set in the background? I created my own Browser Extension for that... https://chrome.google.com/webstore/detail/lknhpplgahpbindnnocglcjonpahfikn

它仅适用于您选择的特定域.您可以在扩展程序的设置中为 cookie 自定义您自己的唯一 NAME 和 VALUE.

It works just for the specific domains that you choose. You customize your own unique NAME and VALUE for the cookies in the extension's settings.

只要一组人使用相同的 NAME/VALUE 对,这种方法就可以很容易地使用,因此开发人员、内容创建者、校对人员和您组织中的其他任何人都可以查看页面,而不会增加统计数据.

This method can easily be used by a team of people as long as they use the same NAME/VALUE pair, so developers, content creators, proofreaders, and anyone else in your organization can all view pages without inflating the statistics.

随意分享我的解决方案并使用我的扩展程序来设置这些 cookie.

Feel free to share my solution and use my extension to keep those cookies set.

这篇关于如何从动态 IP 地址中排除 Google Analytics 中的流量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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