Disable Google Analytics from Tracking You
With over 65% of the top one-million websites using Google Analytics (according to BuiltWith), it should give you pause and make you think about how all of this information is being used. We even use Google Analytics on GeekThis to view how many visitors frequent each page. If you are unaware, Google Analytics is a website statistics service that tracks and reports traffic. Google Analytics tracks the acquisition of visitors, what pages visitors frequent, how long they spend on each page, and much more. The information that is presented to the website owner doesn’t include personal information, but a lot of information can still be gathered about the visitors (or specific visitor) to a website.
There are a few reasons to opt-out of Google Analytics. The first is to partially prevent websites from tracking your activity. Google Analytics can track various on-page events such as clicking on a video, clicking on a link to go to a different website, or how long you are spending on a web-page. Websites can still track what pages you visit on their site though by using server logs. Secondly, preventing Google from having information on websites you visit is a large reason to start opting out of Google Analytics. Finally, if you’re a web developer, opting out of Google Analytics is a quick way to prevent seeing traffic from yourself inside of your reports when you are testing a new page.
Google Analytics Opt-Out Extension
The official extension used to opt-out of Google Analytics is the easiest way to opt-out and should always work even when Google makes changes to their services. There are a few downsides to the extension though. First, the extension has to be installed to your computer. Installing software to stop other software from tracking your activities seems a little counter productive. Google using an extension instead of the regular cookie opt-out methods does have the benefit of the opt-out being more permanent and won’t unknowingly stop working when you clear your cookies. Secondly, the extension doesn’t prevent Google from knowing what websites you visit. The extension works by preventing events from being sent to Google Analytics, but the Google Analytics JavaScript still is fetched from Google’s servers and the HTTP request includes the Referer HTTP header which contains the current page you are on.
If you decide that the Google Analytics Opt-Out Extension is right for you, visit the download link below. It works on Google Chrome, Firefox, Internet Explorer, Opera, and Safari.
Block Google Analytics using a Firewall
If you have the ability to block IP ranges or domain names through a
firewall, then blocking Google Analytics for your whole network is
another option. I generally avoid blocking services by IP addresses
since the IP addresses can change without notice or multiple services
might use the same IP address. If your firewall can block DNS requests
to specific domain names, then adding a rule to block the domain
google-analytics.com
and www.google-analytics.com
would prevent
Google Analytics. Keep in mind that Google Analytics is loaded over
HTTPS, after the DNS request you most likely won’t be able to block the
request unless you block IP ranges or if the server uses
SNI.
Block Google Analytics using the Hosts File
Before a DNS request is performed, the local hosts
file is used to
see if the host name / domain name has been assigned a specific IP
address. Similar to blocking Google Analytics DNS request, you can
assign a domain to a different IP address inside the hosts
file.
Depending on your operating system, the steps will vary, but this
method is possible with Linux, Windows, and OS X. Below are the steps
to block Google Analytics for Microsoft Windows. What we are going to
do is assign the Google Analytics domain name to a non-existent IP
address, causing any request to be terminated instead of being sent to
Google.
- Run Command Prompt as an administrator. This can be done by searching for “cmd” and then right click on the entry for “cmd” and then click on “Run as administrator.” For Windows 10 users, you can right click on the Start Icon and then click on “Command Prompt (Admin).”
- Type in the command
notepad "C:\Windows\System32\drivers\etc\hosts"
- At the bottom of the text file add a new line with the value of
0.0.0.0 google-analytics.com
along with a line for the domainwww.google-analytics.com
. - Save the text file and then close out of all web browsers you have opened. Sometimes you will need to restart your computer for changes to take place.
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
0.0.0.0 google-analytics.com
0.0.0.0 www.google-analytics.com
Using a Script Blocker / Disabling JavaScript
A final method to block Google Analytics is to use an extension that blocks JavaScript from loading from specific domains and for specific services. There are numerous extensions available that can block loading JavaScript from specific domains and services. You could also disable JavaScript inside your web browser, but almost every site now requests JavaScript to run properly.
Final Notes
Blocking Google Analytics is a start but the owners of websites ultimately have full control of how they can track you. Whenever you make a request to a website, your request is usually saved to a server log and the website owners can view what pages you visited, your user-agent, IP address, and other information about your request. There are also other popular website statistics services similar to Google Analytics that you should also opt-out of, such as Quantcast.