Sub topic 12
Filtering rows to focus the analysis
This chapter assumes you can already build a Free-form table. You should know how to import dimensions and metrics in the Variables panel, and how to place them in Rows, Columns and Values in Tab Settings. It also assumes you know the difference between event, session and user scopes. Here you will learn how to restrict that table with filters, and where filters differ from segments and from the Data API.
What a filter does in a Free-form exploration
A filter in Tab Settings removes rows from the table based on a condition. It does not change how a metric is calculated. It only decides which rows are displayed. Filters belong to a single tab, so another tab in the same exploration keeps its own filters.
Use a filter when the question is "show me only these rows." Examples are only mobile traffic, only landing pages that contain /blog/, or only channels with more than 100 sessions.
Filters are added in the Filters section of Tab Settings. Click the area that says "Drop or select dimension or metric," choose a field, then define the condition.
Dimension filters and metric filters
A filter uses one field, and the field type decides which conditions are available.
- A dimension filter tests text. You choose a match type and enter a value.
- A metric filter tests a number. You choose a comparison and enter a number.
| Filter type | Typical match types | Example condition |
|---|---|---|
| Dimension | exactly matches, contains, begins with, ends with, matches regex, does not match | Device category exactly matches `mobile` |
| Dimension (list) | matches one of several values | Session default channel group is one of `Organic Search`, `Direct` |
| Metric | equals, greater than, less than, between | Sessions greater than `100` |
Exact option labels can vary slightly between interface versions, so check the drop-down in your property.
Matching is case-sensitive for some match types. A filter such as contains /Blog/ will not match /blog/post-1. If a filter returns an empty table, check the case first.
Combining conditions: AND logic
You can add more than one condition to a filter. Within a single tab, conditions are combined with AND. A row stays only if it satisfies every condition. For example, two conditions on a landing page report might be:
- Device category exactly matches
mobile - Sessions greater than
50
The table then shows only mobile rows with more than 50 sessions.
If you need OR logic across different fields, a filter is the wrong tool. Use a segment with several conditions, or use a regular expression on one field. For OR on a single field, either the "matches one of" option or a regex such as ^(Organic Search|Direct)$ works.
Filters and fields that are not in the table
A dimension filter does not require the field to be in Rows or Columns. You can filter on Device category while showing only channel groups in Rows. This keeps the table small while still restricting the data.
Compatibility rules still apply. A filter field must be compatible with the other fields in the tab. If you add a session-scoped filter to a table that uses an incompatible field, GA4 greys out the field in the Variables panel or refuses the condition. See the scopes chapter for the rules.
A metric filter works on the metric as it appears in each row. If Rows is channel group by device category, a filter of Sessions > 100 is applied to the sessions in each channel and device combination. It is not applied to the channel's total.
Filter or segment?
Filters and segments both narrow the data, but they act at different points.
| Question | Filter | Segment |
|---|---|---|
| What does it restrict? | Rows in the table | Users, sessions or events included in the calculation |
| Can you compare several side by side? | No | Yes, up to the limit for segment comparisons |
| Can it use sequences or user behavior? | No | Yes |
| Can it filter on a metric value? | Yes | Not directly |
| Scope | One tab | Can be reused across tabs and explorations |
The difference matters for metrics that count unique things. Suppose you filter to Device category = mobile and look at users. Each row shows the users who had mobile sessions in that row. A segment of "users who ever used mobile" can give a different number, because it can include all activity from those users, depending on its scope. When the question is about who someone is, use a segment. When the question is about which rows to display, use a filter.
Worked example: landing pages that matter
Suppose you want to review blog landing pages on mobile that bring in meaningful traffic.
- Create a Free-form exploration.
- Import
Landing page + query string(orLanding page),Device category,SessionsandEngaged sessions. - Put
Landing pagein Rows andSessionsandEngaged sessionsin Values. - In Filters, add
Device categoryexactly matchesmobile. - Add
Landing pagecontains/blog/. - Add
Sessionsgreater than50. - Sort by Sessions, descending.
The result shows only mobile blog landing pages with at least 51 sessions. Because filters only hide rows, adding or removing them is safe. The underlying data does not change.
Filters and totals
Be careful with totals. In a table, the totals row can reflect the filtered data or the full data depending on the field and the setting. Do not assume the total equals the sum of the visible rows. This matters especially for users, because a user who appears in two rows is counted once in the total, and the sum of rows may exceed it.
If you need a number for a presentation, check it against another source. A Free-form table with a filter on Device category = mobile and no other changes should be compared with the same view in a standard report that has a mobile comparison applied.
Common errors
- Empty table after adding a filter. The usual cause is a case mismatch, an extra space, or a value that does not exist, such as
Mobileinstead ofmobile. Look at the values GA4 actually reports for that dimension, then copy them. - Regex does not match. GA4 regex must match the whole value in many cases. Use
.*blog.*instead ofblog, or choosecontains. - Metric filter removes too much. Remember that it applies per row. A row that was split by a second dimension may fall below the threshold even if the group total is high.
- Expecting a filter to change totals. A filter hides rows and does not recalculate a metric as if the hidden data never existed.
- Greyed-out fields. An incompatible field cannot be added to the filter. Remove the conflicting field from the table or choose a field with a matching scope.
- Different results than the standard report. Data thresholds, sampling and different attribution defaults can all make two views disagree. A filter on a small group can also push counts below thresholds that the table then hides.
Relating filters to the Data API
A Tab Settings filter on a dimension corresponds to a dimensionFilter in a Data API runReport request. The following request keeps only mobile traffic, like a Device category filter in Tab Settings.
{
"dateRanges": [{ "startDate": "28daysAgo", "endDate": "yesterday" }],
"dimensions": [{ "name": "sessionDefaultChannelGroup" }],
"metrics": [{ "name": "sessions" }],
"dimensionFilter": {
"filter": {
"fieldName": "deviceCategory",
"stringFilter": { "matchType": "EXACT", "value": "mobile" }
}
}
}A metric filter in the interface corresponds to metricFilter. For several conditions joined by AND, the API uses an andGroup that holds a list of expressions. The API is stricter than the interface about field names. It uses deviceCategory, not the label "Device category."
Practical guidance
- Start with a broad table, then add filters one at a time and watch how the rows change.
- Name the tab after its filters, for example "Mobile blog pages," so that a shared exploration explains itself.
- Prefer a segment when you must compare groups side by side or use a behavior-based definition.
- Prefer a filter for ranking and cleanup, such as removing
(not set)or low-volume rows. - Write down your filter conditions when you share results, because they are easy to forget and change the meaning of every number.
Exercise
You built a table with Landing page in Rows and Sessions in Values. You add the filter Sessions greater than 100, and several pages with more than 100 total sessions disappear. You then notice Device category is also in Rows. What explains this, and how would you fix it?
Show answer
A metric filter applies to each row. With Device category in Rows, each landing page is split into one row per device, and a page whose sessions are spread across devices can have every row at or below 100 even though its total is higher. To fix it, remove Device category from Rows (or move it to Columns only if row totals are what you need to filter on), so each landing page is a single row, then reapply the filter.
Exercise
Write the Tab Settings conditions, and name the Data API field that would carry the first one, for a table that keeps only rows where Device category is exactly tablet and Landing page contains /pricing.
Show answer
Condition 1: Device category exactly matches tablet. Condition 2: Landing page contains /pricing. Within one tab the conditions combine with AND. In the Data API, the first condition is a stringFilter with matchType EXACT on the field deviceCategory. Both conditions would go in an andGroup of expressions under dimensionFilter.