Advanced filters
Filter by collections, aggregates, time, and sequences of behavior.
Use advanced filters to qualify sessions or visitors by their activity. Open Filter, choose a scope, and build the condition under Advanced or paste an expression. Funnel steps and goal conditions accept field predicates only. The dashboard-level filter is configured separately.
Scope and reporting
| Automatic scope | Query examples |
|---|---|
event | Overview, pages, events, performance, and retention |
session | Session list and session activity |
visitor | Visitor list and visitor activity |
| — | Realtime and individual record details |
Suppose a visitor opens /pricing and /checkout in one session, then /help in another. In an overview covering both sessions, page.path eq "/pricing" qualifies the /pricing observation in Event scope, the session containing /pricing and /checkout in Session scope, and the visitor with all three pages in Visitor scope. Report metrics still use their own counting rules and selected date range.
A saved filter can specify a scope. When comparing two datasets, their expressions can differ but both sides must resolve to the same concrete scope. Check the editor’s syntax help for the fields available on the current page.
Collections and reducers
PAGE, EVENT, SESSION, and VISITOR are uppercase collection roots. In { ... }, $.member refers to the current item. Conditions inside one selector must match the same item. In Session scope, the first expression below can match a session that visited both pages. The second asks one page to have both paths and matches nothing.
PAGE { $.path eq "/pricing" } exists AND PAGE { $.path eq "/checkout" } existsPAGE { $.path eq "/pricing" AND $.path eq "/checkout" } existscount returns zero for an empty collection. first, last, and nth pick an item in occurrence order. nth starts at 1, and a position with no item has no value. Use .member after a single-item reducer, and -> member to project a collection for sum, avg, min, max, or countDistinct. Use numeric members with sum and avg. The example assumes /amount is sent as a JSON number.
nth(PAGE, 2).path eq "/checkout"countDistinct(PAGE -> path) gte 5sum(EVENT { $.name eq "purchase" } -> payload("/amount")) gt 1000Time and history
time(first(PAGE)) gets an item's occurrence time. @now uses the query clock, while @range.start and @range.end use the selected report bounds. Add elapsed offsets such as @now-14d. A standalone time condition can set the activity range for Session or Visitor scope when used in the top-level AND domain. The report range still determines which activity appears in the report. Unbounded collection expressions may require the site’s stored history, so first(PAGE) can refer to a page before the displayed range.
| Function | Meaning |
|---|---|
bucket | bucket(PAGE, 1d) maps page observations to calendar buckets. countDistinct counts distinct buckets. |
periods | periods(EVENT, 1w) yields nonempty calendar weeks. $items refers to the matching items in the current week. |
window | window(collection, anchor, [startOffset, endOffset]) keeps items on or after the start and strictly before the end. The anchor can be a page or event occurrence, @now, or a report bound. Offsets are relative to that anchor. |
Calendar periods such as 1d or 1w use the query time zone. Elapsed offsets in window measure duration from the anchor. For example, [0d, 7d] includes the anchor instant and excludes the instant exactly seven elapsed days later.
time(last(PAGE)) gte @now-14dFor example, this matches a session or visitor with at least three events in any one calendar week.
periods(EVENT, 1w) { count($items) gte 3 } existsSequences
sequence([...]) matches ordered steps. Use Session scope to keep them in one session, Visitor scope to allow different sessions for the same visitor, or place the sequence inside an explicit SESSION { ... } or VISITOR { ... } selector. adjacent(sequence) requires consecutive timeline positions, including intervening pages and events. without(sequence, collection) excludes matching activity strictly between the matched steps.
Inside the sequence selector, $span is the duration from first to last step, and $gap(1, 2) is the duration between steps 1 and 2. $same($.payload("/productId")) requires every step to be an Event that records the same product ID. Add that condition only if both signup and purchase send the field.
sequence([EVENT { $.name eq "signup" }, EVENT { $.name eq "purchase" }]) {
$span lte 14d AND $gap(1, 2) lte 7d AND $same($.payload("/productId"))
} existsTo require that the sequence occurs in a single session while reporting at Visitor scope, wrap it in a session selector.
SESSION { sequence([EVENT { $.name eq "signup" }, EVENT { $.name eq "purchase" }]) exists } existsExamples with expected results
Purchase with no refund in seven days
Choose Visitor scope. Under Advanced, require the first purchase to exist, then check for the absence of refund events in a window anchored to that purchase. A visitor with a purchase and a refund six days later fails. With a refund exactly seven days later, the visitor matches. A visitor with no purchase fails the first condition. This checks any refund event for the visitor. It assumes the seven days have already elapsed when you interpret the result.
first(EVENT { $.name eq "purchase" }) exists AND window(EVENT { $.name eq "refund" }, first(EVENT { $.name eq "purchase" }), [0d, 7d]) notExistsActive on three distinct days in one week
In the dashboard, select one complete calendar week in the reporting time zone and choose Visitor scope. Restrict the filter’s activity range to the report bounds, then count distinct daily page buckets. Page views on Monday, Wednesday, and Friday match. Three views on Monday alone do not. This uses page views and needs no custom event.
time gte @range.start AND time lt @range.end AND countDistinct(bucket(PAGE, 1d)) gte 3Signup followed by purchase within seven days
Choose Visitor scope and add a two-step sequence with a seven-day gap limit. The signup and purchase events must be tracked. Signup on day 1, a help-page view on day 2, and purchase on day 6 match. An earlier purchase or one more than seven days after signup does not match that signup.
sequence([EVENT { $.name eq "signup" }, EVENT { $.name eq "purchase" }]) { $gap(1, 2) lte 7d } existsLimits and troubleshooting
The DSL accepts up to 65,536 UTF-16 code units. Filter documents have default limits of 16 nesting levels, 128 conditions, and 64 groups. If the expression parses but fails when applied, check the query scope, whether the page exposes the selected field, and whether payload keys and types match the collected data. When results look surprising, test the innermost selector on its own in the intended scope.