防止 Google 分析在开发环境 ASP.NET MVC 中收集数据 [英] Prevent Google analytics from gathering data in development environment, ASP.NET MVC

查看:21
本文介绍了防止 Google 分析在开发环境 ASP.NET MVC 中收集数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ASP.NET MVC (3) 应用程序并且我已经设置了 Google 分析.问题是,每次我从 Visual Studio 运行时,Google 脚本都会开始收集数据,这当然会影响实际结果.

I have an ASP.NET MVC (3) app and I've set Google analytics up. The problem is that every time I run from Visual Studio the Google script starts gathering data, which of course, skews the real results.

防止 Google Analytics 在开发环境中收集数据的最佳方法是什么除了使用丑陋的 #if 每个页面上的编译器指令我要分析?

What's the best way to prevent Google Analytics from gathering data on the development environment other that using ugly #if compiler directives on every page I want analysed?

最佳实践是什么?

谢谢.

推荐答案

Google 建议的最佳做法是使用过滤器从您的 GA 配置文件中删除数据.这可以通过基于开发机器的 IP 地址进行过滤或通过在用于开发和测试的每个浏览器中设置自定义变量 cookie 来完成.这种方法意味着您无需修改​​主体代码即可删除数据.

The best-practice advised by Google is to use a filter to remove the data from your GA profiles. This can either be done by filtering based on the IP address of development machines or by setting a custom variable cookie in each browser being used for development and testing. This approach would mean you could remove the data without needing to modify your main body of code.

这篇关于防止 Google 分析在开发环境 ASP.NET MVC 中收集数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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