How to Prevent Google Analytics from Tracking You

Updated: 22 April 2021
Updated: 22 April 2021

Miklos Zoltan

Fact-checked by

Google Analytics is a free tool by Google that provides robust insights into website visitor performance and statistics.

In this guide you will learn about:

  • Why you should not want Google Analytics to track you
  • Methods to prevent Google Analytics from tracking you

Many businesses integrate Google Analytics into their websites to track visitor statistics and gather valuable web metrics.

However blocking Google Analytics is more widespread now due to various privacy concerns. Once a person blocks Google Analytics, that person is not being tracked, and nothing is sent to Google Analytics servers.

This article will explain some popular methods out there to prevent Google Analytics from tracking you.

How to Prevent Google Analytics from Tracking You

Why You Should Block Google Analytics from Tracking You

Tracking user behavior is very beneficial for website owners. The collected data can be used for marketing, conversion rate optimization, user experience (UX) improvement, auditing, and so on.

In general, Google Analytics will collect at least the following information from the guests of a website.

  • The amount of time visitors spend on the website and on each page
  • What are the searches that led them to the content they viewed
  • The particular actions of visitors when they’re accessing the pages
  • Individual IP addresses of visitors and the browsers they use

All the above information sounds harmless. However, when websites and apps start sharing data with each other, it gets to the point where marketers can get a creepily accurate image of you. For some visitors, this is unnerving, and they may get annoyed with the relentless stream of targeted ads.

On the other hand, the information users provide to websites is their price to get better product recommendations, search results, specific offers, etc. Abstractly, all these help towards a better web experience.

However, if they want to opt-out of tracking, it should be within their ability to do so.

Methods to Block Google Analytics from Tracking You

Below I’ll be showing you several methods you can implement in order to prevent Google Analytics from tracking your browsing and internet activity.

1. Installing Google Analytics Opt-Out extension

Using this official extension is the best way to opt-out from Google Analytics. The main advantage of using the Opt-Out extension is that you can make sure it always works even when Google makes changes to its services.

However, there are also some downsides to this extension. One is that you have to install it on your computer. Installing software to stop other software from tracking your activities is not very productive. The other disadvantage is that this extension can’t stop Google from knowing about the websites you visit. It just blocks sending events to Google Analytics.

The Google Analytics Opt-Out Extension works with all major browsers, including Google Chrome, Firefox, Safari, Internet Explorer, and Opera.

Google Analytics Opt-Out

2. Installing the “Block Yourself from Analytics” Chrome extension

Another simple method to block Google Analytics is using a Chrome extension called “Block Yourself from Analytics.” When installed, it restricts Google Analytics from tracking your visits to specific websites. What’s interesting about this extension is that it allows you to set a list of domains you don’t want your visits to get tracked.

Below are the steps to install and setup the “Block Yourself from Analytics” Chrome extension.

Step 1: Open Chrome browser

Step 2: Visit this link to find the extension.

Step 3: Click on the blue “Add to Chrome” button and click “Add Extension” in the following popup.

Block Yourself From Google Analytics

Press “Add Extension”.

Block Yourself From Google Analytics Extension

Step 4: Now, you can see an orange icon in your browser’s top right as below.

How to Block Google Analytics From Tracking You - Chrome Extension

Step 5: Now, navigate the website that you don’t want your visits to get tracked by Google Analytics. Then click on that small orange icon on the browser and click “Block Analytics for this website.”

You can also manually add (without navigating to the website) any website/websites you want or view the list of websites you have blocked by clicking on “Options.” To manually add a website using the “Options” area, enter the URL of the website in the text field at the bottom of the window and click “Add.” In the end, make sure to save all the websites you added before exiting.

Block Yourself From Google Analytics Extension - Options

The main drawback of this method is that it only works with the Chrome browser.

3. Using a firewall to block Google Analytics

If you have a firewall that can block specific IP ranges or domain names, you can block Google Analytics for your entire network. This option also has some downsides, such as IP addresses changing without notice or multiple services using the same IP address. If your firewall can block DNS requests to particular domain names, you can add a rule to block the domain google-analytics.com and www.google-analytics.com to opt-out Google Analytics.

4. Using Hosts file to block Google Analytics

You can also opt-out Google Analytics by assigning the domain name to a different IP address in the hosts file. That is because the local hosts file is checked to see if the host name/domain name is assigned a particular IP address before serving a DNS request.

This is similar to blocking the DNS request of Google Analytics, which we discussed earlier. The steps of this method will vary depending on your operating system, but it works with OS like Linux, Windows, and macOS.

Following are the steps to opt-out Google Analytics for Microsoft Windows. Here, we are going to assign the domain name of Google Analytics to a non-existing IP address, leading any request to it getting terminated instead of sending it to Google.

Step 1: Run Command Prompt in administrator mode.

To do that, search for “cmd” in the search bar and right-click on the “Command Prompt” entry that appears there.

Then click on the “Run as administrator” option, and it will launch the Command Prompt as an administrator.

Windows 10 users will have to right-click on the Windows Icon and select “Command Prompt (Admin).”

Step 2: Type the below command in the Command Prompt.

notepad “C:\Windows\System32\drivers\etc\hosts”

It will open up the hosts file on your computer.

Step 3: Add a non-existing IP for Google Analytics.

Add two lines at the bottom of the hosts file as following:

0.0.0.0 google-analytics.com
0.0.0.0 www.google-analytics.com

Step 4: Finally, Save the hosts file and close all the open web browsers.

Sometimes, you may need to restart your computer for these changes to become effective.

Edit Hosts File - Google Analytics Opt-Out

5. Using Ad-Blockers

Ad blockers have gained more attention recently due to their wide usage. While their main purpose is to block the annoying (marketing) ads that follow you across the internet, they also have the ability to affect the process of collecting traffic data in various means, such as by blocking Google Analytics.

Ad Blockers do that by blocking any attempts of Google Analytics JavaScript library to transfer data between websites and analytics servers.

By default, many ad blockers blacklist Google Analytics, while some ad blockers need to be configured to do so.

  • The uBlock Origin is a popular ad blocker that comes as a Chrome extension. It blocks Google Analytics by default and is used by more than 10 million users.
  • The Adblock Plus Chrome extension can be used to block Google Analytics by enabling the Easylist option.

Below are a few simple steps to install and configure Adblock Plus free ad blocker and configure it to block Google Analytics.

Step 1: Visit the Chrome Web Store page of the Adblock Plus extension.

Adblock Plus Extension

Step 2: Click on the “Add to Chrome” button and then click on the “Add Extension” button in the following popup.

Adblock Plus Add to Chrome

Step 3: Now, you will see a small Adblock plus icon in your browser, and it will display a popup when you hover on it.

Using Adblock Plus

Step 4: Click on the Settings icon of the top right of the popup and go to the “Advanced Tab” of the settings page.

Adblock Plus Advanced Settings

Step 5: Turn on the “Easy List” option there to block Google Analytics.

In addition to the above two ad blockers, there are also some other popular ad blockers that are capable of blocking Google Analytics, such as AdBlock Pro, AdGuard AdBlocker, AdRemover, Ghostery, Simply Block Ads! and SuperBlock Adblocker.

5. Using the Brave Browser

Brave is an open-source, Chromium-based web browser that is free to download and use. It is similar to all the other standard browsers in enabling users to navigate websites, view any online content, and run web applications.

However, the major differentiating factor of Brave among other Chromium browsers is its focus on user privacy. Brave achieves this by blocking all ads, third-party cookies, and website trackers like Google Analytics by default. Therefore, using Brave browser is a good option for hiding your online activity from Google Analytics while surfing the web.

Since the Brave browser also acts as an ad blocker, blank spaces will appear in the areas of websites that contain ads. Sometimes, the pages won’t load properly and in such cases, you will have to either select a different browser or change the ‘Shields Up’ setting to ‘Shields Down’ to turn off the privacy and security protection of Brave.

Below are few simple steps for downloading and installing the Brave browser.

Step 1: Visit the following link to navigate to the official site of Brave browser.

Step 2: Then, click on the required download option in the middle of the page, and it will download the installable file of the Brave browser.

Download Brave

Step 3: Double click on the installable file, and it will generate a prompt message as shown below. Click “Run” there, and it will install and launch Brave browser on your PC.

That’s it.

Looks and works like any other web browser:

Brave Browser

6. Using a Script blocker to disable JavaScript

Finally, you can also use an extension that blocks JavaScript from loading for particular domains or servers to opt-out Google Analytics. There are numerous extensions that are capable of serving this purpose.

You can even disable JavaScript from your web browser. But this method is not recommended since almost all modern websites require JavaScript to run properly and blocking JavaScript will break most website from loading properly.

Final Thoughts

Data is invaluable, and nowadays, most websites collect at least some basic information about their visitors’ behavior.

As a powerful web analysis tool, Google Analytics allows to track a wide range of data regarding website performance, traffic, and even user behavior.

However, it is also important that website users feel safe while visiting websites, and for that, they may need to exercise more control over who’s monitoring their online habits.

Therefore, even if blocking Google Analytics can affect the accuracy of analytics data for site owners, it’s a major privacy concern for visitors.

Written by: Shanika W.

Connect with the author:

Shanika Wickramasinghe is a software engineer by profession. She works for WSO2, one of the leading open-source software companies in the world. One of the biggest projects she has worked on is building the WSO2 identity server which has helped her gain insight on security issues. She is keen to share her knowledge and considers writing as the best medium to do so. Cybersecurity is one of her favorite topics to write about.

Being a graduate in Information Technology, she has gained expertise in Cybersecurity, Python, and Web Development. She is passionate about everything she does, but apart from her busy schedule she always finds time to travel and enjoy nature.

Leave a Reply

Your email address will not be published.