(First published in 2600 Magazine Volume Twenty-Five, Number Three.)
I'm sure most 2600 readers are aware of Google Analytics, a handy
way for owners of websites to see what their visitors get up to
without having to learn how to analyze Apache log files.
The more paranoid amongst you may have worked out that Google have
a lot of information at this point. From Analytics alone they can
keep track of which web pages people look at, not just on individual
sites but from one website to the next, providing that all these
sites use Analytics - which increasingly more web developers are
recommending to their clients due to its ease of use.
As someone who values her privacy and likes tinkering around with
computers, I thought it would be a fun little project to stop my
computer from talking to Google Analytics. It only takes a few
minutes, and the effect will last until whenever Google decides to
change the URL of their JavaScript file that keeps track of people
browsing the web - which will probably be quite some time as they'd
need to tell a lot of people to update every page of their website.
Redirecting your browser
As you can see by simply viewing the HTML source of any site that
uses Google Analytics, the program that keeps track of your movements
on the web is available at http://www.google-analytics.com/urchin.js,
so you may want to tell your computer not to access that particular
domain name.
To do this, edit your /etc/hosts file, which keeps track of which
domain names go to which IP addresses. (It's in a different directory
in Windows, but GNU/Linux and OS X users should be able to pop open
a terminal application and just start editing it using sudo or su
and the text editor of your choice. If in doubt, search online for
more details.) This is the line you need to add:
127.0.0.1 www.google-analytics.com
Once you save the file, your computer will think that any traffic
for that domain name should go to itself, not the real site, so it
won't actually talk to the real Google Analytics server anymore.
Finding out who uses Analytics
If you're running Apache and know how to set up domain names on it,
things get a little bit more fun. You can tell Apache that it is
indeed the server that should receive requests for files on that
domain name by editing httpd.conf and setting up a directory to host
that domain's files from. (If you're not familiar with Apache, you'd
do well to read up on it first - it's notoriously finicky about its
configuration file.)
The simplicity of setting up Analytics is vital for its popularity,
which means it's also very simple to serve the appropriate file
locally. Just create a plain text file called urchin.js in your new
directory and type the following into it:
function urchinTracker() {
window.status = 'This site tried to contact Google Analytics';
}
That's it! Whenever you access a site that tries to monitor your
activity using Google Analytics, your web browser will instead tell
you about it by writing a message in your browser's status bar.
Naturally, you can change this script to do whatever you wish.
(Bear in mind that Firefox doesn't let JavaScript programs write to
the status bar by default. Should you wish, you can override this
by going to its preferences, clicking on the "content" tab, clicking
on the "advanced" button next to the tickbox to enable JavaScript
and ticking "Change status bar text.")