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-v2.md
+64-12
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@ API keys have a rate limit of 600 requests per hour by default. If you have spec
47
47
48
48
Domain of your site on Plausible to be queried.
49
49
50
-
### date_range <Required />
50
+
### date_range <Required /> {#date_range}
51
51
52
52
Date range to be queried.
53
53
@@ -63,7 +63,7 @@ Date range to be queried.
63
63
|`"year"`| Since the start of this year |
64
64
|`"all"`| Since the start of stats in Plausible |
65
65
66
-
### metrics <Required />
66
+
### metrics <Required /> {#metrics}
67
67
68
68
Metrics represent values to be calculated with the query.
69
69
@@ -91,13 +91,28 @@ List of dimensions to group by.
91
91
Dimensions are attributes of your dataset. Using them in queries enables analyzing and compare multiple groups against each other.
92
92
Think of them as `GROUP BY` in SQL.
93
93
94
+
#### Event dimensions
95
+
94
96
Valid dimensions include:
95
97
96
98
| Dimension | Example | Description |
97
99
| --- | --- | --- |
98
100
|`event:goal`| Register | A custom action that you want your users to take. To use this dimension, you first need to configure some goals in the site settings, or via the Sites API. Learn more about goals here. |
99
101
|`event:page`| /blog/remove-google-analytics | Pathname of the page where the event is triggered. You can also use an asterisk to group multiple pages (/blog*) |
100
102
|`event:hostname`| example.com | Hostname of the event. |
103
+
:::warning
104
+
105
+
Mixing session metrics `bounce_rate`, `views_per_visit` and `visit_duration` with event dimensions is not allowed.
106
+
:::
107
+
108
+
109
+
#### Visit dimensions
110
+
111
+
Values of these dimensions are determined by the first pageview in a session.
112
+
113
+
114
+
| Dimension | Example | Description |
115
+
| --- | --- | --- |
101
116
|`visit:entry_page`| /home | Page on which the visit session started (landing page). |
102
117
|`visit:exit_page`| /home | Page on which the visit session ended (last page viewed). |
103
118
|`visit:source`| Twitter | Visit source, populated from an url query parameter tag (utm_source, source or ref) or the Referer HTTP header. |
@@ -118,16 +133,26 @@ Valid dimensions include:
118
133
|`visit:country_name`| United States | Name of the visitor country. |
119
134
|`visit:region_name`| California | Name of the visitor region. |
120
135
|`visit:city_name`| San Francisco | Name of the visitor city. |
136
+
137
+
#### Time dimensions {#time-dimensions}
138
+
139
+
It's useful to be able to group data by time, which can be done via the following dimensions.
140
+
141
+
| Dimension | Example | Description |
142
+
| -- | -- | -- |
121
143
|`time`| 2024-01-01 | Time or date to group by. Automatically figures out the appropriate time:bucket value from date range. Response is a valid ISO8601 date or timestamp |
122
144
|`time:hour`| 2021-01-27T23:43:10Z | Time grouped by hour. ISO8601 |
123
145
|`time:day`| 2021-01-27 | Time grouped by date |
124
146
|`time:week`| 2021-01-04 | Time grouped by start of the week |
125
147
|`time:month`| 2021-01-01 | Time grouped by start of month |
126
148
127
-
:::warning
149
+
Note that:
150
+
-`time` dimensions are not usable in filters. Set [`date_range`](#date_range) instead.
151
+
- If no data falls into a given time bucket, no values are returned. [See `include.time_labels` option](#time-labels) for a workaround.
128
152
129
-
Mixing session metrics `bounce_rate`, `views_per_visit` and `visit_duration` with event dimensions is not allowed.
130
-
:::
153
+
Note behavior when no data matches - nothing returned. See time-labels.
154
+
155
+
Not usable in filters.
131
156
132
157
#### Custom properties
133
158
@@ -162,6 +187,27 @@ Note that only `is` operator is valid for `event:goal` dimension.
162
187
163
188
List of values to match against. A data point matches filter if _any_ of the clauses matches.
164
189
190
+
### order_by <Optional />
191
+
192
+
Allows for custom ordering of query results.
193
+
194
+
List of tuples `[dimension_or_metric, direction]`, where:
195
+
-`dimension_or_metric` needs to be listed in query [`metrics`](#metrics) or [`dimensions`](#dimensions) respectively.
0 commit comments