View Source PlausibleWeb.Api.StatsController (Plausible v0.0.1)
Summary
Functions
See PlausibleWeb.Controllers.API.Revenue.format_revenue_metric/1
.
Returns a time-series based on given parameters.
Parameters
This API accepts the following parameters:
period
- x-axis of the graph, e.g.12mo
,day
,custom
.metric
- y-axis of the graph, e.g.visits
,visitors
,pageviews
. See the Stats API "Metrics" section for more details. Defaults tovisitors
.interval
- granularity of the time-series data. You can think of it as aGROUP BY
clause. Possible values areminute
,hour
,date
,week
, andmonth
. The default depends on theperiod
parameter. CheckPlausible.Query.from/2
for each default.filters
- optional filters to drill down data. See the Stats API "Filtering" section for more details.with_imported
- boolean indicating whether to include Google Analytics imported data or not. Defaults tofalse
.
Full example:
%{
"from" => "2021-09-06",
"interval" => "month",
"metric" => "visitors",
"period" => "custom",
"to" => "2021-12-13"
}
Response
Returns a map with the following keys:
plot
- list of values for the requested metric representing the y-axis of the graph.labels
- list of date times representing the x-axis of the graph.present_index
- index of the element representing the current date inlabels
andplot
lists.interval
- the interval used for querying.with_imported
- boolean indicating whether the Google Analytics data was queried or not.imported_source
- the source of the imported data, when applicable. Currently only Google Analytics is supported.full_intervals
- map of dates indicating whether the interval has been cut off by the requested date range or not. For example, if looking at a month week-by-week, some weeks may be cut off by the month boundaries. It's useful to adjust the graph display slightly in case the interval is not 'full' so that the user understands why the numbers might be lower for those partial periods.
Full example:
%{
"full_intervals" => %{
"2021-09-01" => false,
"2021-10-01" => true,
"2021-11-01" => true,
"2021-12-01" => false
},
"imported_source" => nil,
"interval" => "month",
"labels" => ["2021-09-01", "2021-10-01", "2021-11-01", "2021-12-01"],
"plot" => [0, 0, 0, 0],
"present_index" => nil,
"with_imported" => false
}