Internet Privacy

Mort Yao

1 How to block Google Analytics (from tracking you)

1.1 Option 1. The official (questionably working) way

Install the Google Analytics Opt-out Browser Add-on.

Note the following claims on their description page:

Updates to your browser or operating system may affect the functionality of the opt-out extension.

So even if it does work, it may stop working without you noticing it. See Option 2 for a more proper solution.

1.2 Option 2. The brutal (and the only correct) way

Add this one line to your /etc/hosts:

So your browser will not even have a chance to see the tracking code ( or

1.3 Notes

Note that although this method effectively blocks Google Analytics’ tracking code, it is normally not possible to know whether there are other pieces of JavaScript engaged in traffic tracking activities on a Web page. Google Analytics is just the most commonly-used and the cheapest (free) one, used by many sites without visitors’ consent.

Also, be aware that the method here does not prevent the server itself logging your activities; nor does it protect you from eavesdropping.