Watch two short videos about how to create segments.
Create a custom segment from scratch.
Create a custom segment from a suggested segment.
In this article:
Create a segment
To open the segment builder:
- Sign in to Google Analytics.
- On the left, click Explore.
- Select an existing exploration or create a new one. Show me how.
- On the left, in Tab Settings, in the Segments section, click the plus sign.
You have three options for creating a new segment:
- Create a custom segment by defining all the parameters yourself.
- Start with a suggested segment. These are based on common use cases and allow you to modify and adapt them to your specific needs.
- Right-click a data point in your visualization to open the context menu, then select Create segment from selection.
Segment date range and condition time period
When you create a segment, one of the variables you can set is the date range for the data included in the segment (e.g., Last 7 days, Last 28 days, or a custom range).
Depending on the type of condition you create to define your segment, you can base the condition on the
event_count metric, which gives you the option to specify that the condition must have been met within a certain time period (e.g.,
event_count > 5 in any 5-day period).
In order to get the results you expect, the condition time period should be less than or equal to the segment date range. It's possible to set the condition time period to be longer than the segment date range, but the segment can never include more data than what is included in the date range.
Create a custom segment
- In the top panel, select the type of segment you want to create (see below for more information on the types of segments you can create).
- Enter a name and description for the segment. This lets you identify the segment elsewhere in Analytics.
- Click Add new condition to specify the selection criteria for this segment. You can create conditions that evaluate dimensions or events. For example:
- Age is one of 18-24 or 25-34
- You can also create segments based on a sequence of steps taken by the user. See below for more information about conditions and sequences.
- In the upper right, click SAVE.
Modify a suggested segment
Suggested segments include pre-built and template segments you can use to get started quickly. Segments in the General tab can be used without modification (though you can change them if desired). Templates have conditions already included: you'll just need to provide the values for those conditions.
Types of segments you can create
User segments are subsets of users who engaged with your site or app: for example, users who have previously purchased; users who added items to their shopping carts, but didn’t complete a purchase.
Event segments are subsets of events that were triggered on your site or app: for example, all purchase events made in a particular location; app_exception events that occurred on a specific operating system.
Session segments are subsets of the sessions that occurred on your site or app: for example, all the sessions that originated from a particular advertising campaign.
Set up conditions
Conditions tell Analytics what data to include in or exclude from the segment. To define a condition, you select the data you want to evaluate, choose a comparison operator, then provide a value or range of values. For example, for a segment of users in North America, you'd create a user segment and select the Country ID dimension, use the is one of operator, then provide the values "US," "CA," and "MX."
Types of conditions
You can create conditions that evaluate dimensions, metrics, and events.
Dimension conditions let you build segments based on evaluating dimension values related to your users, such as demographics, geography, and technology.
Metric conditions let you create segments based on predictive metrics, for example, In-app purchase probability is above 90th percentile.
Event conditions let you create segments based on particular details about one or more events. You can include any event parameters sent with the event when it is logged. For example, you can evaluate a level_start event's “level number” or “level name” parameters. (Learn more about Google Analytics 4 events in the gtag.js reference).
Use custom event parameters in segments
A condition's scope determines how broadly or narrowly the conditions are applied.
For user and session segments, you can select:
- Within the same event: all conditions must be met within the same event.
- Within the same session: all conditions must be met within the same session.
- Across all sessions: all conditions must be met during the lifetime of the user. Learn more about how sessions are calculated.
Conditions for event segments must all occur within the same event.
By default, user segments with dimension-based conditions include users when they currently meet the condition and then remove them when they no longer meet the condition.
You can override this behavior by selecting the At any point option. This includes users if they ever met the condition during the report or exploration time period, even if they don't currently satisfy the condition criteria.
Here's an example:
Let's say one of your users visited Brazil 2 months ago but is now currently in a different location. Adding a segment with a condition "Country = Brazil" and a time period of the previous 3 months will evaluate as follows:
- With At any point selected, this condition will still be true today, and that user will be in the segment.
- With At any point unselected, this condition will be false today, and that user will not be in the segment.
You can build segments that contain multiple conditions and arrange those into condition groups. Within a condition group, each condition can be evaluated with AND or OR logic. Using multiple condition groups lets you make a single evaluation of conditions that use different scopes. For example, you can mix conditions "within the same event" and "across all sessions."
Click Add condition group to add a new group to your segment definition. Condition groups are evaluated with AND logic.
To remove a condition group, hover over each condition in the group, then on the right, click X.
Set up sequential conditions for user segments
For user segments, click Add sequence to define conditions that occur in a specific order. For example, these events must happen in the order listed:
- Step 1: first_open
- Step 2: in_app_purchase.
Optionally, you can require that the steps be completed within a specific time period:
- On the right, click Time Constraint.
- Click the toggle, then define the time period in which the whole sequence must occur (for example 30 Minutes).
Click Add step for each additional step you want to include in the sequence.
By default, the conditions you define are "include" conditions: they define the users or events you want to include in your exploration. Click Add condition group to create a condition that excludes users or events.
Select Temporarily exclude users when to exclude users from the segment during periods when they meet the condition.
Select Permanently exclude users when to exclude users from the segment if they've ever met the condition.
Segments first evaluate all your inclusion conditions, then apply any exclusion conditions you've defined.
A segment can have only one exclude group.
Differences between segments in Universal Analytics vs. Google Analytics 4 properties
You can use segments in both Universal Analytics and Google Analytics 4 properties. Fundamentally, segments work the same way in both products. However segments appear in different places, and have a few different features depending upon which kind of property you're using them in.
For Google Analytics 4 properties, segments are only available in Explorations. (If you need to see subsets of data in your reports, you can use comparisons, which also let you focus on subsets of your data.)
You can create segments in Analytics based on sessions or users. In the new Explorations, segments can be based on users, events, or sessions.
Finally, segments in Universal Analytics properties are subject to certain limits that don't apply in Google Analytics 4 properties. Learn more about segments in Universal Analytics properties.
Limits of the segment builder
- You can create up to 10 segments per exploration.
- You can apply up to four segments to an individual exploration technique at one time.
- Segment data is sampled. The sample size used is 100,000,000 rows.