Google Analytics: Query Builder
In this article, we will explain elements and functionality of the Query Builder for Google Analytics through an example. Our goal is to filter organic search values by country.
IN THIS ARTICLE
1. Basic Options
We chose "New users / organic by country" for our query name.
dimensionsparameter breaks down metrics by common criteria, such as by
country(like in our example). When dimensions are requested, values are segmented by dimension value. If a query has no
dimensionsparameter, the returned metrics will provide aggregate values for the requested date range, such as overall pageviews or total bounces.
Same interval last year.
2. Advanced Options
In our case we left this field empty because we want to push all rows for selected intervals.
ANDboolean logic. Filtered queries restrict the rows that do (or do not) get included in the result. Each row in the result is tested against the filter; if the filter matches, the row is retained, and if it doesn't match, the row is dropped.
- Exact match: Aggregate metrics where the country is
- Does not match: Aggregate metrics where the country is not
- Contains substring: Aggregate metrics where the country contains
- Does not contain substring: Aggregate metrics where the country does not contain
- Contains a match for the regular expression: Aggregate metrics where the country starts with
- Does not match regular expression: Aggregate metrics where the country not start with
- Equals: Return results for users where number of sessions is exactly
- Does not equal: Return results for users where number of sessions is not
- Greater than: Return results for users where number of sessions is strictly greater than
- Less than: Return results for users where number of sessions is strictly less than
- Greater than or equal to: Return results for users where number of sessions is
- Less than or equal to: Return results for users where number of sessions is
In our example we set filters to get data only for three selected countries: United States, Australia and GermanyWhen everything mentioned above is set, click "Run query" to show Data preview.
3. Data preview
In Data Preview you will see all values for selected metrics and date ranges. At the bottom you can check total values. Just click on tabs for switching date range.
If you want to sort values by date/time just click on the arrow next to "Date"
When your query is ready, click "Save query." Now a new metric has been created, with the metric name the same as the custom query name.
By default, a metric will be added in the datasource where data is pulled. It is possible to change the target datasource by clicking on "Change target data source" on the top right.
It is possible to rename dimensions (best practice is to rename them before saving the query) by clicking "..." next to "Dimension" and then selecting "Rename dimension".
This function is useful when you want to exclude one or more dimensions. (For example if you want to show data for all Countries except one). Click on "..." next to "Dimension" and select "Skip dimension".
Click on "..." next to "Value" and select "Round values." Enter the number of decimal places to be rounded to into field in popup, and values will be rounded accordingly.