You can use search-and-replace filters to change the data in a reporting view as it's being processed. For example, you can consolidate your hostnames by removing the www. prefix. You can also make your data more human-readable by replacing codes or long pathnames with simpler, more intuitive versions.
How search-and-replace filters work
Search-and-replace filters use regular expressions to find a search string in a filter field and replace it with a replacement string.
Like all filters, search-and-replace filters only apply to hits collected after you've applied the filter to the view (filters cannot change historical data). And (like all filters), search-and-replace filters permanently change your data. Once a search string has been replaced, you can't undo that change. See the Verify your filter section below before applying any filters.
To create a search-and-replace filter:
- Follow the instructions to create a new filter for your view.
- Set the Filter Type to
Custom.
- Click the Select filter type drop-down menu and select
Search and Replace.
- Use the Filter Field drop down menu to select the field (dimension) you want search.
- Enter a regular expression in the Search String field.
- Enter the Replace String. To delete the search string entirely, leave this blank.
- Use the Case Sensitive checkbox if your regular expression is case sensitive. Otherwise, the search will be case insensitive.
Verify your filter
Search-and-replace filters are very powerful, so you want to be sure you've set them up correctly before changing your actual data. There are 2 ways to verify your filter:
1) If your view already has a large number of hits, you can use the Verify this filter link. This will show you what the filter would have done to a selected set of your historical data. You should ALWAYS do this, if possible. (Not all filter types can be verified in this way.)
2) You can also use Tag Assistant Recordings to record an actual flow through your site and see how the filter would affect those hits. You don't have to have matching hits already in the view, since Tag Assistant Recordings captures the hits as you move through the flow.