AI-generated Key Takeaways
-
Order bys define how rows are sorted in the response, allowing for different ordering based on various criteria like event count or event name string.
-
The
OrderBy
object uses a union fieldone_order_by
to specify one type of order by, which can bemetric
,dimension
, orpivot
. -
You can sort results by a metric's values using
MetricOrderBy
, a dimension's values usingDimensionOrderBy
, or a metric's values within a pivot column group usingPivotOrderBy
. -
DimensionOrderBy
allows specifying anorderType
to control how string dimension values are ordered, including alphanumeric, case-insensitive alphanumeric, and numeric sorting. -
PivotOrderBy
usesPivotSelection
to sort rows based on a metric's value within a specific dimension pivot pair.
Order bys define how rows will be sorted in the response. For example, ordering rows by descending event count is one ordering, and ordering rows by the event name string is a different ordering.
JSON representation |
---|
{ "desc": boolean, // Union field |
Fields | |
---|---|
desc |
If true, sorts by descending order. |
Union field one_order_by . Specify one type of order by for OrderBy . one_order_by can be only one of the following: |
|
metric |
Sorts results by a metric's values. |
dimension |
Sorts results by a dimension's values. |
pivot |
Sorts results by a metric's values within a pivot column group. |
MetricOrderBy
Sorts by metric values.
JSON representation |
---|
{ "metricName": string } |
Fields | |
---|---|
metric |
A metric name in the request to order by. |
DimensionOrderBy
Sorts by dimension values.
JSON representation |
---|
{
"dimensionName": string,
"orderType": enum ( |
Fields | |
---|---|
dimension |
A dimension name in the request to order by. |
order |
Controls the rule for dimension value ordering. |
OrderType
Rule to order the string dimension values by.
Enums | |
---|---|
ORDER_TYPE_UNSPECIFIED |
Unspecified. |
ALPHANUMERIC |
Alphanumeric sort by Unicode code point. For example, "2" < "A" < "X" < "b" < "z". |
CASE_INSENSITIVE_ALPHANUMERIC |
Case insensitive alphanumeric sort by lower case Unicode code point. For example, "2" < "A" < "b" < "X" < "z". |
NUMERIC |
Dimension values are converted to numbers before sorting. For example in NUMERIC sort, "25" < "100", and in ALPHANUMERIC sort, "100" < "25". Non-numeric dimension values all have equal ordering value below all numeric values. |
PivotOrderBy
Sorts by a pivot column group.
JSON representation |
---|
{
"metricName": string,
"pivotSelections": [
{
object ( |
Fields | |
---|---|
metric |
In the response to order by, order rows by this column. Must be a metric name from the request. |
pivot |
Used to select a dimension name and value pivot. If multiple pivot selections are given, the sort occurs on rows where all pivot selection dimension name and value pairs match the row's dimension name and value pair. |
PivotSelection
A pair of dimension names and values. Rows with this dimension pivot pair are ordered by the metric's value.
For example if pivots = ('browser', 'Chrome') and metricName = "Sessions", then the rows will be sorted based on Sessions in Chrome.
---------|----------|----------------|----------|----------------
| Chrome | Chrome | Safari | Safari
---------|----------|----------------|----------|----------------
Country | Sessions | Pages/Sessions | Sessions | Pages/Sessions
---------|----------|----------------|----------|----------------
US | 2 | 2 | 3 | 1
---------|----------|----------------|----------|----------------
Canada | 3 | 1 | 4 | 1
---------|----------|----------------|----------|----------------
JSON representation |
---|
{ "dimensionName": string, "dimensionValue": string } |
Fields | |
---|---|
dimension |
Must be a dimension name from the request. |
dimension |
Order by only when the named dimension is this value. |