Skip to content

Commit

Permalink
Improves realtime top stats and conversion rate calculation (plausibl…
Browse files Browse the repository at this point in the history
…e#500)

* Fixes goal conversion rate when period is realtime

* Adds unique visitors (30m) to realtime top stats

* Changelog

Co-authored-by: Uku Taht <Uku.taht@gmail.com>
  • Loading branch information
2 people authored and oliver-kriska committed Dec 23, 2020
1 parent 262054f commit e60a49e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
- Simple notifications around traffic spikes plausible/analytics#453
- Dark theme option/system setting follow plausible/analytics#467
- "Load More" capability to pages modal plausible/analytics#480
- Unique Visitors (last 30 min) as a top stat in realtime view plausible/analytics#500
- Pinned filter and date selector rows while scrolling plausible/analytics#472

### Changed
Expand All @@ -33,6 +34,7 @@ All notable changes to this project will be documented in this file.
- Prevent picking dates before site insertion plausible/analtics#446
- Fix overly-sticky from and to in query parameters plausible/analytics#495
- Adds support for single-day date selection plausible/analytics#495
- Goal conversion rate in realtime view is now accurate plausible/analytics#500

### Security
- Do not run the plausible Docker container as root plausible/analytics#362
Expand Down
1 change: 1 addition & 0 deletions lib/plausible/stats/clickhouse.ex
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ defmodule Plausible.Stats.Clickhouse do
end

def unique_visitors(site, query) do
query = if query.period == "realtime", do: %Query{query | period: "30m"}, else: query
ClickhouseRepo.one(
from e in base_query_w_sessions(site, query),
select: fragment("uniq(user_id)")
Expand Down
4 changes: 4 additions & 0 deletions lib/plausible_web/controllers/api/stats_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ defmodule PlausibleWeb.Api.StatsController do
name: "Current visitors",
count: Stats.current_visitors(site, query)
},
%{
name: "Unique visitors (last 30 min)",
count: Stats.unique_visitors(site, query)
},
%{
name: "Pageviews (last 30 min)",
count: Stats.total_pageviews(site, query)
Expand Down

0 comments on commit e60a49e

Please sign in to comment.