Published on: 20 June, 2016

Disable Google analytics for local development

Posted by andy | 921 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("") == -1) {
//Your google analytics code goes here.

Above code is used to check the url address if it contains the following domain name, 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.


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: 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.
Published on: 16 March, 2016
If you try to search this particular topic in Google Search, you will come up with a list of different solutions. Most of them will use the document or body height to compare if there is a difference, we assume there will be a scroll bar. Unfortunately it doesn't work well, most of them it will return the same height.
Related Tutorials