How to disable and ignore Google Analytics tracking during development
While I was finishing off the last few tweaks of Redlight, an open-source E-Commerce template, I begun to notice my Google Analytics dashboard was recording page views and events from my local development environment. Since I use Google Analytics for a lot of my open-source and client projects, I decided to investigate this further and find a solution.
After a quick Google bashing I found a few answers, but none seemed to be a quick and clean approach to the problem. One of the solutions proposed was to add a custom exclude filter by IP address, however, since I generally work in several different places during my work day, this did not seem to be a viable solution to my problem.
ga('create', 'UA-74266457-1', 'redlight.tomdallimore.com');
As you can see from the above snippet, I have defined the domain for the webpage as an parameter value when creating a ga object. This enables us to restrict the domain for any Google Analytics events and/or page views on your application.
If you would like more information, please check out the Google Analytics documentation:
08th March 2016