How to Fix: Disable Google Analytics in Firefox, Chrome, IE

Dennis Faas's picture

Infopackets Reader Ray F. writes:

" Dear Dennis,

I have a problem with Google Analytics tying up my web browser with a 'waiting for www google-analytics.com' messages every time I visit a site. It shows this message in the action box on the lower left of the browser as the page loads. This goes for about 20 to 40 seconds and will not let me pass it; I have to wait for it to complete before the page will fully load. How do I get rid of this? Thanks for a great website and newsletter. "

My response:

This is a good question. The reason why the analytics is there is so that the website operator can see where his or her visitors are coming from, how much time they spend on certain pages, and most importantly, why visitors are leaving the site. Google Analytics is a very important metric if you are a webmaster. For the most part, Google Analytics should load seamlessly onto a web page without any lag issues - however, if it is causing problems for you, it is possible to disable the tracking using the Windows Hosts file.

How to Fix: Disable Google Analytics from Firefox, Chrome, IE

The Windows Hosts file is a small text file that overrides DNS (domain name services) so that your router or DNS service will be bypassed. In other words, when a website issues a request for your browser to visit www google-analytics.com, the hosts file will be looked up instead and will point to your machine for the IP address. This effectively causes a zero delay in resolving the DNS (since it's using a local IP) and thus the page will load much faster. Using this method should work fine for www google-analytics.com, however if you use it to block advertisements (for example) you may see 404 errors on the page.

For the record, others may recommend that you use things like "ad block plus" and "no script" plugins, but this is truly overkill and will result in broken web pages, rather than simply blocking a request to ping google analytics. In that case, my solution is 100% effective.

To do so:

  1. First, open an administrative command prompt. Click Start, type in "cmd" (no quotes); wait for CMD.EXE or Command Prompt to appear, then right click it and select "Run as Administrator".
     
  2. Next, highlight the text below using your mouse:

    copy c:\windows\system32\drivers\etc\hosts c:\windows\system32\drivers\etc\hosts_backup
    echo 127.0.0.1 analytics.google.com >> c:\windows\system32\drivers\etc\hosts
    echo 127.0.0.1 www.google-analytics.com >> c:\windows\system32\drivers\etc\hosts
    echo 127.0.0.1 google-analytics.com >> c:\windows\system32\drivers\etc\hosts
    echo 127.0.0.1 ssl.google-analytics.com >> c:\windows\system32\drivers\etc\hosts
    echo this is a dummy line
     
  3. Right click over highlighted text above, and select Copy from the dialogue menu. Then, right click in the middle of the administrative command prompt window and select Paste from the dialogue menu. The text you copied in Step #2 should be output to the command line.
     
  4. Close your web browser and try to access a page with Google Analytics that was not previously working. It should be blocked now using the Windows Hosts file.

I hope that helps.

Got a Computer Question or Problem? Ask Dennis!

I need more computer questions. If you have a computer question - or even a computer problem that needs fixing - please email me with your question so that I can write more articles like this one. I can't promise I'll respond to all the messages I receive (depending on the volume), but I'll do my best.

About the author: Dennis Faas is the owner and operator of Infopackets.com. With over 30 years of computing experience, Dennis' areas of expertise are a broad range and include PC hardware, Microsoft Windows, Linux, network administration, and virtualization. Dennis holds a Bachelors degree in Computer Science (1999) and has authored 6 books on the topics of MS Windows and PC Security. If you like the advice you received on this page, please up-vote / Like this page and share it with friends. For technical support inquiries, Dennis can be reached via Live chat online this site using the Zopim Chat service (currently located at the bottom left of the screen); optionally, you can contact Dennis through the website contact form.

Rate this article: 
Average: 5 (7 votes)

Comments

Michael.Townes_2935's picture

After you paste the text into the command window, you must but the enter key to execute the instruction.

Dennis Faas's picture

The final: echo "this is a dummy line" is there to negate the need to press Enter as it is a final command in the sequence, which has no meaning (other than to take the spot of having the press Enter).

dan_2160's picture

Thanks Dennis for posting this solution.

Just in case somebody runs into problems after executing this fix, exactly how would they "undo" the fix?

Dennis Faas's picture

You would need to open an administrative command prompt, then copy and paste the line into the command prompt:

notepad c:\windows\system32\drivers\etc\hosts

Notepad will appear; delete these lines:

127.0.0.1 analytics.google.com
127.0.0.1 www.google-analytics.com
127.0.0.1 google-analytics.com
127.0.0.1 ssl.google-analytics.com

Then save the file.