If you are using Google Analytics 4 (GA4) for your website, you may encounter a peculiar issue where another website sends data to your analytics account using your tracking code. This can happen accidentally, maliciously, or because of bots. Let’s dive into how you can handle this situation effectively.
Example
For instance, when you have a website and wish to track its traffic using Google Analytics, you insert a tracking code on every page of your site. This tracking code contains a Measurement ID, which essentially connects the data your site generates to your analytics account. However, since the code is not hidden, anyone can copy it and place it on their website, intentionally or unintentionally. This results in your Google Analytics account receiving data from someone else’s website as well.
Solution
Currently Google Analytics does not offer a way to block this from happening. You can take steps to ensure that your reports and data views are not affected by this extraneous data.
Filtering Out Data
The best way is to filter out the unwanted data. You can set filters to only view data from your website domain.
- Go to any report within your Google Analytics account.
- Click on “Add Comparison” at the top.
- Under “Hostname”, specify only your domain name.
- Click on Apply.
By applying this filter, you can ensure that all the data you review is from your domain.
NOTE: by using the "hostname" comparison, you can see the domain of the site that is sending data to you.
Blocking Via Google Tag Manager
Another solution is available if the other party copied your Google Tag Manager (GTM) code instead of your Google Analytics code. In this case, you can create a filter in GTM to block the extraneous data.
- Go to your Google Tag Manager account.
- Set up a trigger that only sends data to Google Analytics if the hostname matches your domain.
This approach stops GTM from sending data to Google Analytics if the hostname is not your domain.