Remove spam from your Google Analytics historical data
The spam that is already stored in your Analytics (or any data for that matter) can't be permanently deleted. That is why it is important to also create filters to stop receiving junk traffic.
However, you can still clean your past data affected by spam using a segment.
To help you get started, I created a segment template that you just need to fill in with your "valid hostname expression" and the pre-built expressions I prepared for you.
Clean segment template for Google Analytics
- Import the template from the Google Analytics gallery. (Don't use Safari browser or it won't work. In general, I recommend using Chrome when working with GA it just works better)
- Select the view where you want to import the segment and click create,
- Fill the placeholders with the pre-built expressions listed below. You will need to add or remove conditions to the segment depending on the expressions you will use for your analytics.
- To Remove a condition click on the minus - sign to the right of the correspondent field.
- To Add click on the OR button of the exclude section then on the first drop-down select the field you want to add and in the second dropdown matches regex and copy the expression on the text box
- Once everything is set Save the segment. Whenever you need to analyze "polluted" data, you can select it from your segment list.
a. Standard expressions
a. Standard expressions
b. Special expressions
b. Special expressions
If you use 3rd party tools that send data to your Google Analytics via Measurement protocol (ie. Callrail), the expressions below need to be tested before using them.
Remember the hostname regex is the same one you created for the hostname filter. Here are the instructions to create a valid hostname expression in case you missed it.
This is the only expression that goes in the INCLUDE section of the segment
c. Historic expressions
c. Historic expressions
The following expressions are only needed if you are analyzing data before February 2020.
Want to get notified of expression updates and new filters?
After saving the segment, you will be able to see spam-free reports, as long as the segment is selected.
Do you have any questions or feedback?
I've tried to cover all the important details in this guide, however, if there is any part where you are experiencing difficulties, please let me know in the comments section below.
If this article helped you, please consider sharing it or leaving a comment below on your experience, it just might help other people! Need help implementing, configuring, and/or protecting your Google Analytics? I can help!
If you need help with this or any other Google Analytics configuration/customization.