mirror of
https://github.com/plausible/analytics.git
synced 2024-12-23 01:22:15 +03:00
* Add referrers to csv (#2624) * Change CHANGELOG * add missing files * fix tests * revert package files changes * fix typo * format * rename
This commit is contained in:
parent
8c3b541971
commit
9e26ea2cdf
@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Add `referrers.csv` to CSV export
|
||||
### Fixed
|
||||
- Only return `(none)` values in custom property breakdown for the first page (pagination) of results
|
||||
- Fixed weekly/monthly e-mail report [rendering issues](https://github.com/plausible/analytics/issues/284)
|
||||
|
@ -701,6 +701,35 @@ defmodule PlausibleWeb.Api.StatsController do
|
||||
end
|
||||
end
|
||||
|
||||
def referrers(conn, params) do
|
||||
site = conn.assigns[:site]
|
||||
|
||||
query =
|
||||
Query.from(site, params)
|
||||
|> Filters.add_prefix()
|
||||
|
||||
pagination = parse_pagination(params)
|
||||
|
||||
metrics = [:visitors, :bounce_rate, :visit_duration]
|
||||
|
||||
res =
|
||||
Stats.breakdown(site, query, "visit:referrer", metrics, pagination)
|
||||
|> add_cr(site, query, pagination, :referrer, "visit:referrer")
|
||||
|> transform_keys(%{referrer: :name})
|
||||
|
||||
if params["csv"] do
|
||||
if Map.has_key?(query.filters, "event:goal") do
|
||||
res
|
||||
|> transform_keys(%{visitors: :conversions})
|
||||
|> to_csv([:name, :conversions, :conversion_rate])
|
||||
else
|
||||
res |> to_csv([:name, :visitors, :bounce_rate, :visit_duration])
|
||||
end
|
||||
else
|
||||
json(conn, res)
|
||||
end
|
||||
end
|
||||
|
||||
def referrer_drilldown(conn, %{"referrer" => "Google"} = params) do
|
||||
site = conn.assigns[:site] |> Repo.preload(:google_auth)
|
||||
|
||||
|
@ -145,7 +145,8 @@ defmodule PlausibleWeb.StatsController do
|
||||
'operating_systems.csv' => fn -> Api.StatsController.operating_systems(conn, params) end,
|
||||
'devices.csv' => fn -> Api.StatsController.screen_sizes(conn, params) end,
|
||||
'conversions.csv' => fn -> Api.StatsController.conversions(conn, params) end,
|
||||
'prop_breakdown.csv' => fn -> Api.StatsController.all_props_breakdown(conn, params) end
|
||||
'prop_breakdown.csv' => fn -> Api.StatsController.all_props_breakdown(conn, params) end,
|
||||
'referrers.csv' => fn -> Api.StatsController.referrers(conn, params) end
|
||||
}
|
||||
|
||||
csvs =
|
||||
|
@ -0,0 +1,2 @@
|
||||
name,conversions,conversion_rate
|
||||
Direct / None,1,25.0
|
|
@ -0,0 +1,2 @@
|
||||
name,visitors,bounce_rate,visit_duration
|
||||
Direct / None,1,0,60
|
|
2
test/plausible_web/controllers/CSVs/30d/referrers.csv
Normal file
2
test/plausible_web/controllers/CSVs/30d/referrers.csv
Normal file
@ -0,0 +1,2 @@
|
||||
name,visitors,bounce_rate,visit_duration
|
||||
Direct / None,4,75,15
|
|
2
test/plausible_web/controllers/CSVs/6m/referrers.csv
Normal file
2
test/plausible_web/controllers/CSVs/6m/referrers.csv
Normal file
@ -0,0 +1,2 @@
|
||||
name,visitors,bounce_rate,visit_duration
|
||||
Direct / None,5,80,12
|
|
Loading…
Reference in New Issue
Block a user