Filter queries restrict the data included (or excluded) in your report. A filter will test each value of your report: if the filter matches, the row is kept otherwise it's discarded.
Below we explain how to use the filter query syntax. If you have more in-depth questions, we recommend the official Google Analytics filter query syntax reference.
Filter syntax
name operator expression
name - the name of the dimension or metric to filter on. For example,
ga:pageviews
filters on the pageviews metric.operator - the comparison (greater than, less than, equals, etc) to match
ga:name
. There are different operators for dimensions (words) or metrics (numbers).expression - the number, to match against the metric or phrase to match against the dimension.
Filter syntax: name
You can use the Dimensions and Metrics Reference to find the ga:name
for any dimension or metric.
The ga:name
is the ID of a dimension or metric. For example, ga:pageview
, ga:bounceRate
, or ga:pagePath
.
Filter syntax: metric operators
Metric Operators
Operator Description Example
----------------------------------------------------------------------
== Equals ga:timeOnPage==10
Return results where the time on
the page is exactly ten seconds
!= Does not equal ga:timeOnPage!=10
Return results where the time on
the page is not ten seconds
> Greater than ga:timeOnPage>10
Return results where the time on
the page is strictly greater than
ten seconds
< Less than ga:timeOnPage<10
Return results where the time on
the page is strictly less than ten
seconds
>= Greater than or ga:timeOnPage>=10
equal to
Return results where the time on
the page is ten seconds or more
<= Less than or ga:timeOnPage<=10
equal to
Return results where the time on
the page is ten seconds or less
Filter syntax: dimension operators
Dimensions Operators
Operator Description Example
----------------------------------------------------------------------
== Exact match ga:city==Irvine
Aggregate metrics where the city
is Irvine
!= Does not match ga:city!=Irvine
Aggregate metrics where the city
is not Irvine
=@ Contains substring ga:city=@York
Aggregate metrics where the city
contains York
!@ Does not contain ga:city!@York
substring
Aggregate metrics where the city
does not contain York
=~ Contains a match ga:city=~^New.*
for the regular
expression Aggregate metrics where the city
starts with New
!~ Does not match ga:city!~^New.*
regular expression
Aggregate metrics where the city
does not start with New
Filter syntax: expressions
There are a couple of rules that you will want to keep in mind:
Semicolons: must be escaped with a backslash, like this
\;
Commas: must be escaped with a backslash, like this
\,
Regular expressions: always case-insensitive and cannot be longer than 128 characters
Filter syntax: combining filters
You can combine filters using OR
and AND
boolean logic.
Filter syntax: combining filters using OR
The OR
operator is defined using a comma (,
).
A few examples are:
Country is either United States OR Canada
ga:country==United%20States,ga:country==Canada
Firefox users on Windows OR Macintosh operating systems
ga:browser==Firefox;ga:operatingSystem==Windows,ga:operatingSystem==Macintosh
Filter syntax: combining filters using AND
The AND
operator is defined using a semi-colon (;
).
A few examples are:
Country is United States AND the browser is Firefox
ga:country==United%20States;ga:browser==Firefox
Operating system is (Windows OR Macintosh) AND browser is (Firefox OR Chrome)
ga:operatingSystem==Windows,ga:operatingSystem==Macintosh;ga:browser==Firefox,ga:browser==Chrome
Country is United States AND sessions are greater than 5
ga:country==United%20States;ga:sessions>5
Complete reference
Please visit the official Google Analytics filter query syntax reference for more details.
Filter queries are a Premium feature of Arc Analytics.