Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Google analytics from gathering data in development environment, ASP.NET MVC

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.

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?

What would be a best practice?

Thanks.

like image 576
Sergi Papaseit Avatar asked Mar 01 '11 20:03

Sergi Papaseit


People also ask

How do I disable Google Analytics development?

To disable Analytics programmatically, set the following window property to true : window['ga-disable-GA_MEASUREMENT_ID'] = true; Replace GA_MEASUREMENT_ID with the Analytics ID of the property that you would like to disable.

What is integration of Google Analytics?

The integration with Google Play allows you to access your in-app purchase and subscription event data from Play in Google Analytics. You can use this information, for example, to define audiences or measure the performance of ad campaigns (if you have linked your ad accounts).


1 Answers

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.

like image 164
Ewan Heming Avatar answered Sep 20 '22 01:09

Ewan Heming