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

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

问题描述

谷歌检测到不寻常的流量很不错。但是它是如何处理动态IP地址的?



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



如何在Google Analytics中解决这类问题。我也知道如何从单个IP和IP范围中排除流量,但我不知道如何阻止其IP每天更改的内部流量?

>即使您有幸找到IP范围,如果您在咖啡店或酒店工作,该怎么办?
  • 检查主机名可消除开发环境中的命中,但是如果我在调试实时网站?

  • 编辑服务器配置令人讨厌/高级,并且多个域名变得复杂。点击所有网站或根本没有任何要求。
  • 因此,我将其他几个解决方案合并为一些内容为我工作...




    • 无论我走到哪里,它都伴随着我
    • 它在开发环境和live / p上工作ublic域名

    • 它仅影响到我和我正在开发的网站

    • 只需点击一下即可打开/关闭

    • 很容易验证它确实没有将任何数据发送到分析

    • 它可以被整个团队使用

    • ul>

      我随时在我的计算机上设置一个开发人员cookie,仅限于我管理的域。这个cookie具有独特的价值,这对我来说是特定的。然后,我只需在将 任何数据发送到Google Analytics(分析)之前,在脚本中检查此Cookie 。将代码放到我的页面中...

      $ p

      $ b pre $ if(window.location.host ===mydomain.com|| window.location.host ===www.mydomain.com){
      if(document.cookie。 indexOf(COOKIENAME = COOKIEVALUE)=== -1){
      //在此处插入分析代码
      }
      }
      $ b

      PHP

        if($ _SERVER ['HTTP_HOST'] ===mydomain.com|| $ _SERVER ['HTTP_HOST'] ===www.mydomain.com){
      if(@ $ _ COOKIE [COOKIENAME]!= =COOKIEVALUE){
      //在此插入分析代码
      }
      }

      验证主机名称等于我的现场网站(mydomain.com)的域名可确保任何访客在从测试域中查看分析数据时都不会发送,例如localhos t或beta.mydomain.com。在上面的例子中,www.mydomain.com和mydomain.com是我希望访问被记录的两个有效域。



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



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



      它适用于您选择的特定域名。您可以为扩展程序设置中的Cookie自定义您自己的唯一名称和值。



      只要用户使用相同的NAME,该方法可以轻松地被一群人使用/ VALUE对,因此开发者,内容创建者,校对人员和组织中的其他人都可以查看网页,而不会夸大统计数据。



      欢迎分享我的解决方案并使用我的扩展保持cookie的设置。

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

      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!

      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?

      解决方案

      There are problems with many of the popular answers to this question...

      • Even if you're lucky enough to find an IP range, what if you're working from a coffee shop or hotel?
      • Checking host name eliminates hits from a dev environment, but what if I'm debugging the live site?
      • Editing server configurations is annoying/advanced and multiple domains become complicated.
      • Opt-Out extensions either block hits on all websites or none at all depending on who you ask.

      So, I combined several other solutions into something that works for me...

      • It follows me wherever I go
      • It works on a dev environment and on live/public domains
      • It only affects me and the sites that I'm developing
      • It turns on/off with one click
      • It's easy to verify that it is truly not sending any data to analytics
      • It can be used by a whole team of people

      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
         }
      }
      

      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.

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

      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

      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.

      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.

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

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

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