Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Fixed bounce rate calculation.

Mike Cao2addb96e4b0c
diff --git a/components/metrics/MetricsBar.js b/components/metrics/MetricsBar.js
index 18a1a43b8..00238fbef 100644
--- a/components/metrics/MetricsBar.js
+++ b/components/metrics/MetricsBar.js
@@ -35,7 +35,7 @@ export default function MetricsBar({ websiteId, startDate, endDate, className })
<MetricCard label="Visitors" value={uniques} format={formatFunc} />
<MetricCard
label="Bounce rate"
- value={uniques ? (bounces / uniques) * 100 : 0}
+ value={pageviews ? (bounces / pageviews) * 100 : 0}
format={n => Number(n).toFixed(0) + '%'}
/>
<MetricCard
diff --git a/lib/queries.js b/lib/queries.js
index 3bfc27fed..258d910f8 100644
--- a/lib/queries.js
+++ b/lib/queries.js
@@ -236,7 +236,7 @@ export function getMetrics(website_id, start_at, end_at) {
`
select sum(t.c) as "pageviews",
count(distinct t.session_id) as "uniques",
- sum(case when t.c = 1 then t.c else 0 end) as "bounces",
+ sum(case when t.c = 1 then 1 else 0 end) as "bounces",
sum(t.time) as "totaltime"
from (
select session_id,
@@ -260,7 +260,7 @@ export function getMetrics(website_id, start_at, end_at) {
`
select sum(t.c) as "pageviews",
count(distinct t.session_id) as "uniques",
- sum(case when t.c = 1 then t.c else 0 end) as "bounces",
+ sum(case when t.c = 1 then 1 else 0 end) as "bounces",
sum(t.time) as "totaltime"
from (
select session_id,