Improve your Google Analytics reporting accuracy by filtering out unwanted or spam traffic. This helps you focus on real user behavior and make better business decisions.
Before you begin
Before you can filter unwanted traffic, ensure you meet these requirements:
- You are signed in to a Google Account with access to the Google Analytics property.
- You know the specific domains or patterns of the unwanted traffic you want to filter out.
Step 1 of 4: Modify events for unwanted traffic
You need to modify events to identify the traffic you want to filter out. To do this:
- In Admin, under “Data display”, select Events.
Note: The previous link opens to the last Analytics property you accessed. You can change the property using the property selector. You must be a Viewer or above at the property level to modify events in Analytics.
- Select Custom configurations.
- Select Custom events and choose a data stream.
- In the “Custom events” table, click an event to modify.
- Under “Matching conditions”, select Add condition.
- Set the parameter to
page_location
. - Set the operator to “matches regular expression”, “contains”, or “starts with”.
- Enter the domain of your unwanted traffic in the “Value” field. You can set the filter to only include or exclude a specific value, which can be a hostname. For example, a hostname that doesn’t begin with “example.com” will be identified as spam.
- Set the parameter to
- Under “Modify parameters”, select Add modification.
- Set the parameter to
traffic_type
. - Set the new value to “spam”.
- Set the parameter to
- Click Save.
Step 2 of 4: Create a data filter
You can use the internal traffic type settings to create a data filter and exclude unwanted traffic. To do this:
- In Admin, under “Data collection and modification”, select Data filters.
Note: The previous link opens to the last Analytics property you accessed. You must be signed in to a Google Account to open the property. You can change the property using the property selector. You must be an Editor or above at the property level to create a data filter.
- Select Create filter.
- Select Internal traffic.
- Enter a name for the data filter. The name must:
- be unique among data filters in the same property
- begin with a unicode letter
- contain only unicode letters and numbers, underscores, and spaces
- contain up to 40 characters
- Choose Exclude and ensure that the value of the
traffic_type
parameter is “spam”. - Choose from the following filter states:
- Testing: Analytics identifies matching data with the "Test data filter name" dimension. You can use this to validate your data filters before you activate them.
- Active: Analytics applies the data filter to incoming data and makes permanent changes.
- Inactive: Analytics isn't evaluating the filter.
- Click Create.
Step 3 of 4: Validate your traffic filter
You must test your data filter before setting it to active to confirm that it works as expected. If you set the data filter to Testing, wait for 24-36 hours before you validate.
Build a validation exploration
- In Explore, under “Start a new exploration”, select the Free form template.
- In the “Dimensions” panel, add Test data filter name and Event name.
- In the “Metrics” panel, add Event count.
- Drag Test data filter name and Event name into the “Rows” panel.
- Drag Event count into the “Values” panel.
- In the “Filters” panel, add Test data filter name.
- Set the match type to “contains” and enter the exact name of your data filter.
- Click Apply.
Verify the result
If the filter works, the table should show “Event counts” next to your data filter’s name. This means that traffic that matches your criteria, such as traffic_type = spam
, is flagged for exclusion.
Step 4 of 4: Activate your traffic filter
After validating your data filter, you can now activate it to permanently filter out the unwanted traffic from your data. To do this:
- In Admin, under “Data collection and modification”, select Data filters.
- Click the data filter you validated.
- Under “Filter state”, select Active.
- Click Save.
Note: After you set a filter to Active, it will begin to filter data within 24-36 hours.