Using Filters in GA4
EPA content related to Google Analytics is changing.
Google's legacy platform, Universal Analytics (UA), will reach end of life in mid-2023 with a one-time extension for contracting clients such as EPA until July 1, 2024. See KB article.
In these Web Analytics pages, content for Universal Analytics is marked "Google Universal Analytics (legacy)."
Content for the new platform, Google Analytics 4, is marked "Google Analytics 4 (GA4)."
Filters are the most basic method available in GA4 to limit the data displayed in a report. Segments are a more complex alternative.
- What is a Filter?
- Filtering for a Web Area
- Sets of Specific Links
- For www3: Including All Appropriate Aliases
- For www3: Note on Index Pages
What is a Filter?
A filter limits data displayed in a single report in GA4. A filter can be applied individually or with other filters.
A filter is made up of three elements:

- a Dimension or Metric
- chosen from Dimensions and Metrics in the variables section of the analysis
- a match type or filter operator
- see the lists below
- an expression
- the value to which the dimension or metric is being compared
Match types are selected from options in a drop-down menu. These options are:
For numeric data:
- = (equals)
- > (greater than)
- < (less than)
- != (not equal)
- <= (less than or equal)
- >= (greater than or equal)
For textual data:
- exactly matches
- contains
- begins with
- ends with
- matches regex
- does not exactly match
- does not contain
- does not begin with
- does not end with
- does not match regex
Examples of common filters:
Filter | Purpose |
---|---|
Page path + query string EXACLY MATCHES "/lead" | Limit report to only the single page |
Page path + query string BEGINS WITH "/lead" | Limit report to all page in a web area |
Event name EXACTLY MATCHES "page_view" | Limit report to only page view events |
Link URL ENDS WITH "P001938734.pdf” | Limit report to only the single PDF document |
Page referrer BEGINS WITH "https://www.epa.gov/water-research" | Limit report to only page views where the previously viewed page was in the water research web area |
A report's filters are at the bottom of the Tab Settings column in GA4:

Filtering for a Web Area
The primary strategy available in GA4 to filter reports for a web area is modeled below. For example, these steps will create the filter: Page path + query string BEGINS WITH "/lead"
- Go to Explore
- Open an existing exploration or start a blank one.
- Be sure this dimension is added to the VARIABLES in the analysis: Page path + query string
- In the FILTERS area of the report, start creating a new filter:
Drag the dimension to this area or click on "Drop or select dimension or metric"- Choose the dimension for the new filter: Page path + query string
(The list contains only dimensions of the analysis from the Variables section.) - Click on "Select match type" under FILTERS and choose the match type (operator) "begins with" from the list (scroll to see more options).
- With match type chosen, click on "Enter expression." Type /lead for the lead web area. As you type, selectable options appear based on what you type. Hit tab to leave the box or click the desired entry. Click Apply.
- The filter is now active in the report. You can click the filter again to edit or remove it.
- Choose the dimension for the new filter: Page path + query string
NOTES:
- When entering values for filter expressions for URLs, notice the automatic suggestions. These are clues to the field's data in Google. If the suggestions include https:// then begins with filter expressions must include this to be able to match.
- Page path + query string values do NOT begin with https://, they start with / (e.g., "/lead")
- Page referrer values begin with https://www.epa.gov (e.g., "https://www.epa.gov/lead")
- Landing page + query string values do NOT begin with https://, they start with / (e.g., "/lead")
- Do not include the closing forward slash after "lead". The forward slash excludes the web area homepage from the report.
- Use begins with as the filter match type to ensure the report only includes URLs with a root directory of "/lead," rather than pages that have a subdirectory of "/lead/." If, on the other hand, you wanted results for all URLs containing the word “lead,” you could use match type of contains and filter to simply the word "lead."
Sets of Specific Links
You can query Google Analytics for a list of specific URLs. For this, use the dimension Page path + query string.
- Prepare the list of URLs by removing the domain (e.g., https://www.epa.gov ) so you end up with a list like EXAMPLE below. (This does not work with WCMS "/node/xxxxxx" numbers.) EXAMPLE:
/urban-air-toxics/integrated-urban-air-toxics-strategy
/aboutepa/about-office-mission-support
/indoor-air-quality-iaq/indoor-air-quality-iaq-frequently-asked-questions - Put the characters ".*" at the end of each URL. These are RegEx metacharacters that become necessary with GA4 matches regex filters because of a change in the way RegEx is implemented in GA4. (By default, regular expressions in Universal Analytics properties are treated as a "partial match." In a Google Analytics 4 property, the default regex is a "full match." )
See: https://support.google.com/analytics/answer/1034324?hl=en for details. - Put a pipe (a vertical bar "|") between each URL. Remove all returns and all spaces so it's one long line. Wrap the whole thing in (parentheses). EXAMPLE:
(/urban-air-toxics/integrated-urban-air-toxics-strategy.*|/aboutepa/about-office-mission-support.*|/indoor-air-quality-iaq.*) - Copy the list to your clipboard.
- Log into Google Analytics. Then:
- Go to Explore
- Go to an exploration you want to add this filter to
- Under Variables, ensure you have the dimension Page path + query string added
- In the FITLERS area, start to create a new filter on Page path + query string Drag the dimension to this area or click on "Drop or select dimension or metric"
- For match type, select "matches regex."
- For filter expression, click the text box and paste (CTRL-V) your string of URLs. Then click Apply.
- Wait. The report display will update based on the new filter.
Creating WWW3 Reports Using All Appropriate Aliases
This information only applies to www3 content. TSSMS areas have no practical application in EPA’s Google Analytics account.
In Google Analytics, pages are identified in two ways: (1) URL path and (2) page title. In order to create reports on specific Web areas, you will need to filter by one of these methods.
- Filtering by page title can ensure that aliases are included in your report, since aliased pages share the same title, but this is only practical when creating reports that include a small number of pages or when every page shares part of the Page Title.
- Since a Web area can have hundreds of different page titles, you will most likely need to filter by URL path in order to create a report. Before attempting this, ensure that you have a list of any and all aliases for the Web areas you want to include in your report. You must include all aliases in your URL path filters.
In GA4, the easiest way to include aliases in a report is to create a filter using regular expressions and use the filter match type "matches regex." The pipe character (“|”) equates to “and/or” when creating filters. Use the pipe character to create a filter for multiple directories, including aliases.
- To filter on URL path, use the GA4 dimension Page path + query string
- To use regular expressions in the filter, choose match type of matches regex
- To include multiple aliases in the filter expression, string them together with a pipe "|" between them and each URL followed by two characters ".*" which act as a wildcard to catch any page in the web area. For exampe: "/(Webarea.*|alias1.*|alias2.*)"
The filter would look like this:
Page path or query string MATCHES REGEX "/(Webarea.*|alias1.*|alias2.*)"
Note on Index Pages (WWW3 only)
- …/directory/
- …/directory/index.htm or …/directory/index.html (depending on the file extension)