Sub topic 11
Comparing audiences with segments
A segment is a saved subset of your GA4 data. In a Free-form exploration you can place up to four segments side by side and see how each one performs on the same dimensions and metrics. This chapter assumes you can already build a table in Tab Settings with rows, columns and values. It covers choosing the right segment scope, building a segment, comparing segments, and the errors that most often cause wrong conclusions.
What a segment does
A segment limits an exploration to the events, sessions or users that match conditions you define. Without segments, your table describes all traffic in the date range. With a segment applied, the same table describes only the matching subset. With several segments applied, you get one column group per segment, which makes differences easy to see.
Segments differ from filters in one important way. A filter removes rows from the table after the data is aggregated. A segment changes which data is aggregated in the first place. Filtering rows to "mobile" shows mobile rows, but a user segment of "people who ever used mobile" includes every event those people generated, including their desktop events.
Segments also differ from audiences. An audience is evaluated going forward and is used for remarketing and activation. A segment in Explore is evaluated against historical data in the date range you choose, so you can build one today and apply it to last month.
The three segment scopes
Every segment has a scope. The scope decides how much of the data is kept once a condition matches.
| Scope | Keeps | Use it to answer |
|---|---|---|
| User | All events from every user who meets the condition at any point in the date range | How do people who did X behave overall? |
| Session | All events from sessions that meet the condition | What happens in sessions that start from X? |
| Event | Only the individual events that meet the condition | How often does this specific event occur? |
The scope follows the data model from earlier chapters. Event-scoped fields describe one hit, session-scoped fields describe a visit, and user-scoped fields describe a person across visits.
Here is an example of how scope changes the result. Suppose a user buys on Tuesday after arriving from email, and on Friday browses on a phone without buying.
- A user segment "made a purchase" includes both the Tuesday and Friday sessions.
- A session segment "included a purchase" includes only Tuesday's session.
- An event segment "purchase" includes only the purchase event itself, so engagement metrics such as engaged sessions will look odd or empty.
Pick the smallest scope that still answers the question. Use user scope when the question is about people, and session scope when it is about visits.
Building a custom segment
You create segments from the Variables panel. Click the plus icon next to Segments, then choose Custom segment. The other options are suggested segments, which are prebuilt, and predictive segments, which depend on predictive metrics being available for your property.
- Choose the type: User segment, Session segment or Event segment.
- Give the segment a name that states the condition, such as "Mobile organic search sessions". Names are what you will read in column headers, so avoid "Segment 1".
- Click Add new condition and choose a dimension or event. For example, choose Device category and set it to exactly
mobile. - Add more conditions. Conditions in the same group are combined with AND. Use OR to add alternatives within a condition.
- Optionally add an exclusion group, which removes users, sessions or events that match.
- Check the summary at the top of the builder, which shows the estimated number of users who match. A very small count is a warning that the condition may be wrong or too narrow.
- Save and apply.
For user and session scopes you can also set a condition scope. In a session segment, you can require that two conditions occur "within the same event" or "within the same session". This choice matters. "Source = google" and "event = purchase" in the same session is not the same as both in the same event, because the source dimension is a session-level value and the purchase event may not carry it as an event field.
User segments can be turned into sequences. A sequence is an ordered list of steps, such as view_item followed by add_to_cart. You can mark each step as directly followed or indirectly followed, and add a time limit between steps. Use this when order matters, such as users who added to cart and then returned from email.
Applying segments to a tab
Creating a segment does not change the table. To apply it, drag it from the Variables panel into Segment comparisons in Tab Settings, or double-click it. A tab can hold up to four segments. Each segment you add becomes a separate set of values for every row.
Here is a typical setup for comparing paid and organic behavior.
- Rows: Landing page + query string
- Values: Sessions, Engaged sessions, Engagement rate
- Segment comparisons: "Organic Search sessions", "Paid Search sessions"
The resulting table shows each landing page twice, once per segment, and you can compare engagement rate directly. Switching the Columns setting to show the segment changes whether segments appear as columns or as extra rows, so try both layouts to see which is easier to read.
You can also click a value in the table and choose to apply a segment to the visible data, or right-click a row to create a segment from it. This is a quick way to turn "people who saw this page" into a reusable segment.
Segments and the numbers in the table
Segments are allowed to overlap. A user who used both mobile and desktop belongs to both a "mobile users" segment and a "desktop users" segment, and is counted in each. Summing the segment columns can therefore exceed the total for all users. This is not a bug. If you need to see the size of the overlap, the Segment overlap technique draws it as a Venn diagram, and you can import the same segments there.
A few other behaviors to watch for:
- Scope and metric mismatch. An event-scoped segment limits a session metric to sessions containing those events, but only the matching events count toward event metrics. Compare it with a session-scoped version before trusting the number.
- Incompatible fields. Adding a segment can make some dimensions or metrics unavailable or greyed out, as described in the chapter on scopes and compatibility. The segment's conditions use fields from a scope, and the exploration must be able to combine them with your rows and values.
- Thresholds and sampling. Small segments are more likely to hit data thresholds when Google signals are on, and segments can push a query toward sampling. If a segment's column looks empty, check the data quality icon at the top of the tab.
- Date range. User segments are evaluated within the exploration's date range. A user who qualified last quarter will not appear if the range covers only this month.
- Sharing. A segment you create is available to you. To let others use it in their own explorations, share it from the segment builder, as the chapter on sharing explains for explorations.
Segments and the Data API
The GA4 Data API runReport method has no segment parameter. The closest equivalent is a dimensionFilter, which behaves like a filter on the result rather than a user-scoped segment. Session-scoped conditions translate reasonably well, because the fields involved are session fields. The following request approximates a session segment "mobile organic search sessions".
{
"dateRanges": [{ "startDate": "28daysAgo", "endDate": "yesterday" }],
"dimensions": [{ "name": "landingPage" }],
"metrics": [
{ "name": "sessions" },
{ "name": "engagementRate" }
],
"dimensionFilter": {
"andGroup": {
"expressions": [
{
"filter": {
"fieldName": "deviceCategory",
"stringFilter": { "matchType": "EXACT", "value": "mobile" }
}
},
{
"filter": {
"fieldName": "sessionDefaultChannelGroup",
"stringFilter": { "matchType": "EXACT", "value": "Organic Search" }
}
}
]
}
},
"limit": 25
}To compare two segments through the API, send one request per segment with a different filter and merge the results yourself. User-scoped segments with sequences have no direct equivalent.
Common errors
- Choosing user scope when the question is about sessions, and then finding that metrics include unrelated visits.
- Combining conditions with AND when OR was meant, which produces a segment with almost no users.
- Treating overlapping segments as mutually exclusive and adding their totals.
- Comparing a segment against a total that includes it, instead of against a matching "everyone else" segment built with an exclusion group.
- Forgetting that an event-scoped segment shows event-level numbers only.
Exercise
A user visits twice. In session one they arrive from email and make a purchase. In session two they arrive from search and only browse. You apply a session segment "included a purchase" and a user segment "made a purchase" and then count sessions in each. What does each segment report, and why do the numbers differ?
Show answer
The session segment reports 1 session, because only the first session contains a purchase. The user segment reports 2 sessions, because the user qualified at some point in the date range, so all of their sessions are kept. The scope decides whether the condition selects sessions or people.
Exercise
You compare "Mobile users" and "Desktop users" user segments and the sum of their users is higher than the total users for the property. Is something wrong, and how can you create two segments that add up to the total?
Show answer
Nothing is wrong. People who used both device types are counted in both segments. To get non-overlapping groups, build a "Mobile only" segment that includes mobile and excludes desktop users, build "Desktop only" the same way in reverse, and handle the remainder as a third group, or use session-scoped segments, where one session has a single device category.