Using Segments 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)."
There are two methods available in GA4 for setting criteria for narrowing the scope of a custom report - segments and filters.
Without segments or filters, reports in GA4 represent all users who interacted with the website in any way during the specified time period. All users, all sessions, all event types. So it is often necessary to limit a report to a set of pages, a web area, or an event type (e.g., page_view or downloads).
Segment | Filter |
---|---|
at analysis level, available for up to 10 reports in the analysis | at report level, applies to only one report |
applied before reports, limiting data available to reports |
applies last, limiting output of a report |
can be complex, allowing inclusion and exclusion, with multiple conditional criteria possible with AND / OR logic | a single condition applied to others in report using AND logic |
On this page:
What is a Segment?
A segment creates a pre-determined subset of all Users, Sessions, or Events, for use in your reports. Segments allow you to combine criteria in ways that filters do not allow.
A segment is defined by criteria, and contains only Users or Sessions or Events for which the criteria match.
For instance, the logic of a segment could be one of the following:
- Find all the sessions that match condition X, and show all the data for those sessions.
Examples:- Find all the sessions that resulted from someone clicking a link on site X (source = X.com)
- Find all the sessions that came from mobile phones (device category = mobile)
- Find all the sessions that came from California (region = California)
- Find all the users that match condition X, and show me all the data for their sessions. GA looks for a user who matches condition X, and then gives you session data for the user where condition X was matched.
(Note: If you select “At any point in time” on a condition, then session data for the User will be returned whether or not condition X was matched as long as condition X was matched for the user in at least one of the sessions during the specified date range.)
Examples:- Find all the users who saw page X (page = X)
- Find all the users who searched for "lead" in our internal search box (search term = lead)
- Find all the users who downloaded a file (event category = download, event label = file path, such as below)
https://www.epa.gov/sites/production/files/2014-02/documents/lead_in_your_home_brochure_land_b_w_508_easy_print_0.pdf
- Find all the Events that match condition X, and include all Users and Sessions connected to them.
- Find all Events that involved a specific page (Page path + query string ExactlyMatches “/lead”)
It is possible to combine multiple page path criteria in one segment using the OR logical operator. This is not possible with filters, where multiple criteria are combined with the AND operator. Many other options exist in segments, such as include/exclude criteria, sequences, AND / OR logic, and criteria groups.

Note: A segment only works within one analysis.
You can only apply segments created in a GA4 analysis to report tabs within that analysis. Create up to ten reports in an analysis, and use the segment in one or across several of the reports. If you go back and edit the segment, data visualized in reports that use the segment will be updated to reflect the changed settings.
Create a Custom Segment
The steps below will create a new Events segment limited to the /lead web area.
-
Go to the Explore tab
-
Enter an existing exploration or begin a new “Free form” analysis.
-
Add segment button
Click the plus sign next to SEGMENTS. -
Segment type
Choose which type of segment to create: User, Session or Event. Or choose from available templates at the bottom of the new segment screen. -
Segment name
Give the segment a name and begin to add a condition.- Click where it says, "Untitled segment" and enter a name for the new segment.
- Below "Include Events when:" click "Add new ..."
-
Select dimension
A box will open up, allowing you to select a dimension.- Click at the top to search for the dimension you want to use. (e.g., type "page path")
- Click the row for the desired dimension
-
Add filter
With the dimension chosen, click Add filter to complete the condition.
-
Filter criteria
Enter the filter's criteria.- Select a match type from the dropdown menu
- For example, choose "Begins with" to include all URLs in the web area.
- In the text box, enter a value appropriate for the dimension. (e.g., "/lead")
NOTE: in GA4, values of the page path & query string dimension begin with the forward slash. - Click Apply
-
Save
With the condition completely entered, click the SAVE AND APPLY button.
You can now analyze a segment for only those Sessions that included at least one epa.gov/lead Pageview. Apply your new segment and browse through the various standard reports. Each report will display only the data associated with your new custom segment.
Including All Appropriate Aliases
When creating a new segment, it is important to include any and all aliases. This is done the same way you would for include/exclude filters.