Published on: 20 June, 2016

Disable Google analytics for local development

Posted by andy | 1062 views 1 likes 2 favourites 0 comments
Tumblr Digg Google Plus

Google Analytics is one of the best free analytics site tracker. It gives you an idea the statistic of your visitors like the country they come from, the URL or keyword they search to go to your site or even the demographic or ages of your visitors. If you are a developer, you definitely do not want to track any data when you are in development phase. There are couple things can be done in here. One of the easy way, you can actually go to your admin console and add an exception of your IP address.

Another option you can is by writing a simple javascript if condition. As we know in order to use the google analytics, you will need to copy and paste the google analytics javascript code. What you can is placing the following if condition code.

if (window.location.href.indexOf("localdevelopmenturl.com") == -1) {
//Your google analytics code goes here.
}

Above code is used to check the url address if it contains the following domain name localdevelopmenturl.com, if it does not find that domain name, it will run the google analytics code. Hope this easy code can help you minimizing unnecessary tracking data.

Comments

There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.
Share your article with us and add your own google adsense account to earn extra money. Plus, you can promote a link back to your site.
Related Articles
Published on: 06 January, 2018
In this tutorial, you will learn how to minify JS and CSS files using Gulp. So what is exactly a Gulp is? Gulp is a javascript task runner, it can be used to perform an automatic tasks such as minifying and bundling files, running unit tests, running code analysis and much more.
Published on: 13 May, 2016
To convert a number value into money format in Javascript can be done easily using Javascript. Firstly you will need to use the built in toFixed function that will return a number value into two decimal point and then using a regular expression to reformat the value.
Related Tutorials