[UA] Search-and-replace filters [Legacy]

Fine-tune the data in your Analytics views.
You are viewing a legacy article about Universal Analytics. Learn more about Google Analytics 4 replacing Universal Analytics.

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.

Search-and-replace filters are not supported for either standard or custom product-level Ecommerce dimensions.

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:

  1. Follow the instructions to create a new filter for your view.
  2. Set the Filter Type to Custom.
  3. Click the Select filter type drop-down menu and select Search and Replace.
  4. Use the Filter Field drop down menu to select the field (dimension) you want search.
  5. Enter a regular expression in the Search String field.
  6. Enter the Replace String. To delete the search string entirely, leave this blank.
  7. 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.

Search-and-replace examples

Was this helpful?

How can we improve it?
true
Choose your own learning path

Check out google.com/analytics/learn, a new resource to help you get the most out of Google Analytics 4. The new website includes videos, articles, and guided flows, and provides links to the Google Analytics Discord, Blog, YouTube channel, and GitHub repository.

Start learning today!

14329807588777150059
true
Search Help Center
true
true
true
true
true
69256
false
false
false
false
Search
Clear search
Close search
Main menu