Did you know that you are being tracked on the internet? Of course you did, everyone knows google is everywhere these days. How else would you see the same adverts for male pattern baldness follow you around from site to site after you went doing research "for a friend".
There was a time when I thought this was no big deal. What harm could it really do if google knew what kind of things I was most interested in buying so they could target advertising for me, it sounded like a win/win situation to me. After all they have a code of conduct that states this on the first line of the first paragraph:
“Don’t be evil.”
However after recent (and not so recent) incidents where google has acted questionably in relation to peoples privacy, I have started to limit my interactions with google services. For reference here are some of the incidents I'm talking about:
Now you could make the argument that individually these can all be explained as missteps or simple mistakes, but put them together and you can't help but start to see a pattern that if not evil, certainly is not that good either.
So what can we do about it? Well one step you can do is to opt out of being tracked by google analytics so that google is less able to track your movements on the web. Now you can download plugins for your browser that can do this for you such as Ghostery (which I personally like a lot), but if you don't want to install a plugin these is a really simple way of doing this using the hosts file.
All the major consumer operating systems have a hosts file which they use as a first point of reference when looking up a web address. Only if an address is not found on this file does the computer then go out to DNS servers to try and resolve a url to an ip. We can leverage this file to block google analytics from tracking us.
As the google analytics code runs from our browsers on our computers it uses the same hostname resolution system to connect to and pass back information to the google-analytics servers. So all we need to do to block this is put in an entry in the hosts file to misdirect it.
To edit the hosts file open notepad (with administrative privileges) and open the file. Note that the hosts file does not have a file extension so when you are browsing the "etc" directory with the file open dialogue make sure that you are showing all files and not just ".txt" files.
With the file open copy in these two entries. These tell your computer that the google-analytics domain is actually hosted on your own computer so that when the analytics javascript code tries to connect to the analytics servers the traffic is misdirected to your computer. The first entry is for regular websites with google analytics installed and the second covers ssl secured websites. Save the file and you are done.
127.0.0.1 www.google-analytics.com
127.0.0.1 ssl.google-analytics.com
Note: While this method tackles the google analytics tracker it does not deal with other systems which may have tracking built in such as addsense or google search itself. This is just one small step down a long road.
Update: I have discovered that windows defender has been deleting the false hosts entry file. I had to disabled it to keep my changes between reboots. Other antivirus programs may do the same.
Finally one word about my own website. Yes I am a hypocrite. Anyone who has a bit of tech savvy (basically anyone who is reading this) can see from my source code that I actually have google analytics code installed on this site at the time of writing this entry.
I do have plans to replace it my own analytics system which will read from my server logs but at the moment I don't have time to finish it. So for the time being I'm keeping it as does provide me with some useful information, but hopefully not for too much longer.