You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/stats-api.md
+58-15Lines changed: 58 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ toc_max_heading_level: 4
5
5
6
6
import { ApiV2Example, ExamplesTip } from '../src/js/apiv2-example.tsx';
7
7
import { Required, Optional } from '../src/js/api-helpers.tsx';
8
-
import { getExampleCode } from '../src/js/examples.tsx';
8
+
import { getExampleCode, EXAMPLE_RESPONSE_META } from '../src/js/examples.tsx';
9
9
import CodeBlock from '@theme/CodeBlock';
10
10
import { SiteContextProvider } from '../src/js/sites.tsx';
11
11
@@ -75,18 +75,49 @@ Metrics represent values to be calculated with the query.
75
75
76
76
Valid metrics are:
77
77
78
-
| Metric name | Description |
79
-
| --- | --- |
80
-
|`visitors`| The number of unique visitors |
81
-
|`visits`| The number of visits/sessions |
82
-
|`pageviews`| The number of pageview events |
83
-
|`views_per_visit`| The number of pageviews divided by the number of visits. Returns a floating point number. |
84
-
|`bounce_rate`| Bounce rate percentage |
85
-
|`visit_duration`| Visit duration in seconds |
86
-
|`events`| The number of events (pageviews + custom events). When filtering by a goal, this metric corresponds to "Total Conversions" in the dashboard. |
87
-
|`percentage`| The percentage of visitors of total who fall into this category: Requires: dimension list |
88
-
|`conversion_rate`| The percentage of visitors who completed the goal. Requires: dimension list passed, an event:goal filter or event:goal dimension |
89
-
|`group_conversion_rate`| The percentage of visitors who completed the goal with the same dimension. Requires: dimension list passed, an event:goal filter or event:goal dimension |
78
+
| Metric name | Type | Description | Requirements |
79
+
| --- | --- | --- | --- |
80
+
|`visitors`|`int`| The number of unique visitors ||
81
+
|`visits`|`int`| The number of visits/sessions ||
82
+
|`pageviews`|`int`| The number of pageview events ||
83
+
|`views_per_visit`|`float`| The number of pageviews divided by the number of visits. ||
84
+
|`bounce_rate`|`float`| Bounce rate percentage ||
85
+
|`visit_duration`|`int`| Visit duration in seconds ||
86
+
|`events`|`int`| The number of events (pageviews + custom events). When filtering by a goal, this metric corresponds to "Total Conversions" in the dashboard. ||
87
+
|`percentage`|`float`| The percentage of visitors of total who fall into this category: Requires: dimension list | Requires non-empty `dimensions`|
88
+
|`conversion_rate`|`float`| The percentage of visitors who completed the goal. | Requires non-empty `dimensions`, `event:goal` filter or dimension being set |
89
+
|`group_conversion_rate`|`float`| The percentage of visitors who completed the goal with the same dimension. Requires: dimension list passed, an event:goal filter or event:goal dimension | Requires non-empty `dimensions`, event:goal filter or dimension being set |
90
+
|`average_revenue`|`Revenue` or null | Average revenue per revenue goal conversion | Requires [revenue goals](docs/ecommerce-revenue-tracking.md), `event:goal` filter or dimension for a relevant revenue goal. |
91
+
|`total_revenue`|`Revenue` or null | Total revenue from revenue goal conversions | Requires [revenue goals](docs/ecommerce-revenue-tracking.md), `event:goal` filter or dimension for a relevant revenue goal. |
92
+
93
+
94
+
<details>
95
+
<summary>Read more about revenue metrics</summary>
96
+
97
+
To use revenue metrics, users should configure [revenue goals](docs/ecommerce-revenue-tracking.md).
98
+
99
+
Revenue metric response type has the following structure:
100
+
101
+
```js
102
+
{
103
+
value: float,
104
+
currency: string, // e.g. "USD" or "EUR"
105
+
short: string, // e.g. "€500.2M"
106
+
long: string, // e.g. "€500,200,700.25"
107
+
}
108
+
```
109
+
110
+
`long` and `short` options are human-friendly formatted results.
111
+
112
+
There are scenarios where revenue metrics can't be calculated. For example:
113
+
1. When no revenue goals are configured
114
+
2. No `event:goal` filter or dimension
115
+
3. No revenue goal matches `event:goal` filter
116
+
4. No `event:goal` dimension and filtered revenue goals have different currencies.
117
+
118
+
In these cases, revenue is returned as `null`s and `response.meta.metric_warning` value will have a warning for why the metric could not
119
+
be calculated. See [response.meta structure](#meta) and [example](#example-revenue-warning)
120
+
</details>
90
121
91
122
### dimensions <Optional /> {#dimensions}
92
123
@@ -313,10 +344,11 @@ Each result row contains:
313
344
-`dimensions` - values for each `dimension` listed in query. In the same order as query `dimensions`, empty if no dimensions requested.
314
345
-`metrics` - List of metric values, in the same order as query `metrics`
315
346
316
-
317
347
### meta
318
348
319
-
Meta information about this query. Related: [include.imports](#include.imports) and [include.time_labels](#include.time_labels).
349
+
Meta information about this query, including warnings and auxiliary data. Related: [include](#include).
0 commit comments