2 ways of veryfying your filters in Google Analytics.
Filters in Google Analytics are an excellent way of organizing the data in your views and blocking spam and other junk traffic, but they can also be a problem if they are incorrectly configured.
Filters effects are permanent, and data lost by a wrongly set filter can't be recovered, so it is important to make sure your filter is ok before you apply it.
Why is important to verify your filter in Google Analytics?
Verifying your filters will let you preview the effects of a filter on incoming traffic before the filter is applied and active.
Benefits of verifying:
- Filter verification lets you see the possible effects of your filter live. It takes time (as much as 24 hours) before filter effects become visible in your data, so you won't know instantly if the filter is working as desired.
- Filter effects are permanent: filtered data cannot be restored to its original, unfiltered state. Filter verification can help you catch errors or problems before you save the filter and possibly impact real data in undesirable ways.
- Filter verification makes trying out variations of your filters much more convenient.
In summary, it will save you time and protect your data by making sure your filters are correctly configured before going live when applying them to the view.
There are two ways of verifying your filters:
- Built-in Verification tool; fast but inaccurate in some cases.
- Using a quick Segment; takes more time to prepare, but it's a lot more accurate.
1. Built-in Verification tool
This built-in feature will allow you to test your filters quickly, but it has some limitations:
- Filter verification uses only a small sample of your data.
- You cannot verify filters for IPs or Geo-based fields.
- You cannot test advanced filters.
How to verify a filter with the built-in feature
To verify a filter in Google Analytics using the built-in feature:
- Create a filter at a View level (Creating it the account level won't work)
- Configure your filter
Verify this filteralmost at the bottom of the window.
- Analyze the “Before” and “After” (you can check some tips below to understand the preview table)
Understanding the filter verification table
- Only data that will be affected by the filter (and is contained in the sample) will be shown in the table.
- The left side of the table shows the rows that would be excluded from your reports after the filter starts working.
- The right side of the preview table shows data that will be included again only if it was excluded previously.
- For Include Filter: the rows on the left side will show records that don't match your filter parameters.
- For Exclude Filter: the left side will show the records that match your filter parameters.
Error: "This filter would not have changed your data"
This is a common issue, especially when creating filters for data that is not regular like filters to clean up the Spam in Google Analytics. When the filter verification can't find a match in the sample data, it will return the following message.
This filter would not have changed your data. Either the filter configuration is incorrect, or the set of sampled data is too small.
That doesn't necessarily mean that your filter is incorrectly configured. There are three possible reasons for this to happen:
Why are you getting the message: "This filter would not have changed your data"
- Incorrect filter configuration: Maybe you made a mistake defining the filter. Check your filter pattern for misplaced or extra characters or spaces. You can use any of these online free tools to check your regular expressions: regex101 or regexr
- The Filter is already saved: If you save the filter and then try to verify it, Google Analytics will consider that there is already a filter saved with the same configuration so this "new filter or version" won't change anything. If you want to verify the filter, you will have to delete it first and then try again.
- There is no match in the Sample Data: If you ruled out the other 2, then it just means that the filter verification tool didn't find any match in the sample data. If this is the case, you should use the second method to verify your filter Quick Segment.
2. Verify the filter using a quick Segment
When the built-in filter verification is not enough, you can use a quick segment to verify your filter. It takes a little more time, but a sampled data won't limit you.
Segments are similar to filters; the difference is that segments are not permanent, and they can be applied retrospectively to any date range.
We will use the box a the top of any of the Google Analytics reports.
How to test a filter with a quick segment?
To test a filter in Google Analytics using a quick segment:
- Go to the corresponding report (if your filter is for referrals[campaign source] go to the referral report, hostnames go to the hostname report and so on)
- Once you are in the correct report, click on the blue text that says
advanced(top of the report next to a search box)
- Configure the segment and click Apply
- 1st dropdown: Whether you are including or excluding in the filter select
- 2nd dropdown: Leave it as it is
- 3rd dropdown: Select
- Text box: Enter the expression you want to verify
- 1st dropdown: Whether you are including or excluding in the filter select
- Click Apply. Now the report below should show all the entries you added to the expression only. If you see more or fewer entries than you want then check for typos, extra characters or extra spaces. TIP: a common mistake is leaving a pipe
|at the end of the expression.
- [Optional] If your filter is complex and you want to make sure that you don't forget any entry, click again on the blue text
Excludethis time without changing anything else. Now go to the report and make sure that you didn't forget any entry.
- For example, if you are creating a Hostname filter for Spam, you shouldn't see any valid hostname on the report.
- Once you are happy with the results go and create your filter.
A simple example
I'll use this example with both verifying methods.
Let's say I want to create a filter to exclude all the data coming from the Desktop version of Facebook. While this can be done in different ways, I will use the Facebook referral identifiers:
Note: Facebook sometimes adds a letter "l" shows like l.facebook.com this is some kind of protection for the privacy of the users.
The first version of the exclude filter (Facebook Desktop) will look like this:
Note: The pipe character
| means OR in REGEX
Admin in GA > Select a View > New Filter > Select Custom Filter > Campaign Souce.
Example with Method 1: Testing the filter with the built-in feature
After clicking on
verify this filter, with the first expression
facebook.com|l.facebook.com, we see in the preview table that all the facebook referrals will be filtered not only the desktop ones.
With this configuration, I will exclude everything not just the Desktop version; this is because custom filters work with regex so everything matching the expression:
To fix it, we have to adjust the filter pattern like this
^facebook.com|^l.facebook.com (The character
^ means "begin with" in REGEX)
After changing the regex and verifying again, we get the desired result.
Now that I verified that the filter would work as expected, I can apply the filter safely.
Example with Method 2: Testing the filter with a quick segment
Following the quick segment verification with the Facebook example (we want to exclude Facebook referrals from desktops/laptops so the ones without an m)
1. We go to the report Referral (Source) report
Note: the facebook referrals with the letter "L" at the beginning are not visible in the screenshot because they are below in the report.
2. Test the expression.
- The First expression
facebook.com|l.facebook.com(The pipe character
|means OR in REGEX)
When we check the report we see also the referrals for Mobile so the expression is not ok.
- The Second expression
^facebook.com|^l.facebook.com(the character ^ means begin with in Regular Expressions)
After fixing the expression the verification shows only the desktop version so the filter will work as expected
By verifying your filters, you will have the security that you aren't losing any valuable data. For a quick test use the built-in feature "Filter verification".
If you are getting the message "This filter would not have changed your data", there is a big chance that the sample data used by the tool is not enough. In that case, use the second method, quick segment, to verify your filter.