Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Show bounce rate in Detail view of Top Entry Pages (#5747)

Adrian Gruntkowski49cff303f4f4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 05669a92e4..9e93636e81 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file.
- All dropmenus on dashboard are navigable with Tab (used to be a mix between tab and arrow keys), and no two dropmenus can be open at once on the dashboard
- Special path-based events like "404" don't need `event.props.path` to be explicitly defined when tracking: it is set to be the same as `event.pathname` in event ingestion. If it is explicitly defined, it is not overridden for backwards compatibility.
- Main graph no longer shows empty values after current time for `day`, `month` and `year` periods.
+- Include `bounce_rate` metric in Entry Pages breakdown.
### Fixed
diff --git a/assets/js/dashboard/stats/modals/entry-pages.js b/assets/js/dashboard/stats/modals/entry-pages.js
index ad61f3d61d..8c166f9d0b 100644
--- a/assets/js/dashboard/stats/modals/entry-pages.js
+++ b/assets/js/dashboard/stats/modals/entry-pages.js
@@ -73,6 +73,7 @@ function EntryPagesModal() {
renderLabel: (_query) => 'Total Entrances',
width: 'w-36'
}),
+ metrics.createBounceRate(),
metrics.createVisitDuration()
]
}
diff --git a/lib/plausible_web/controllers/api/stats_controller.ex b/lib/plausible_web/controllers/api/stats_controller.ex
index 8f33d6570e..325b364f8d 100644
--- a/lib/plausible_web/controllers/api/stats_controller.ex
+++ b/lib/plausible_web/controllers/api/stats_controller.ex
@@ -897,7 +897,7 @@ defmodule PlausibleWeb.Api.StatsController do
params = Map.put(params, "property", "visit:entry_page")
query = Query.from(site, params, debug_metadata(conn))
pagination = parse_pagination(params)
- metrics = breakdown_metrics(query, [:visits, :visit_duration])
+ metrics = breakdown_metrics(query, [:visits, :visit_duration, :bounce_rate])
%{results: results, meta: meta} = Stats.breakdown(site, query, metrics, pagination)
@@ -913,10 +913,11 @@ defmodule PlausibleWeb.Api.StatsController do
:conversion_rate
])
else
- to_csv(entry_pages, [:name, :visitors, :visits, :visit_duration], [
+ to_csv(entry_pages, [:name, :visitors, :visits, :bounce_rate, :visit_duration], [
:name,
:unique_entrances,
:total_entrances,
+ :bounce_rate,
:visit_duration
])
end
diff --git a/test/plausible_web/controllers/CSVs/30d-filter-path/entry_pages.csv b/test/plausible_web/controllers/CSVs/30d-filter-path/entry_pages.csv
index 9ee95b1a87..05da28508d 100644
--- a/test/plausible_web/controllers/CSVs/30d-filter-path/entry_pages.csv
+++ b/test/plausible_web/controllers/CSVs/30d-filter-path/entry_pages.csv
@@ -1,2 +1,2 @@
-name,unique_entrances,total_entrances,visit_duration
-/,1,1,60
+name,unique_entrances,total_entrances,bounce_rate,visit_duration
+/,1,1,0,60
diff --git a/test/plausible_web/controllers/CSVs/30d/entry_pages.csv b/test/plausible_web/controllers/CSVs/30d/entry_pages.csv
index 59330a59cb..640a944b67 100644
--- a/test/plausible_web/controllers/CSVs/30d/entry_pages.csv
+++ b/test/plausible_web/controllers/CSVs/30d/entry_pages.csv
@@ -1,3 +1,3 @@
-name,unique_entrances,total_entrances,visit_duration
-/,3,3,20
-/signup,1,1,60
+name,unique_entrances,total_entrances,bounce_rate,visit_duration
+/,3,3,67,20
+/signup,1,1,0,60
diff --git a/test/plausible_web/controllers/CSVs/6m/entry_pages.csv b/test/plausible_web/controllers/CSVs/6m/entry_pages.csv
index d0f98e9496..61fd1962c7 100644
--- a/test/plausible_web/controllers/CSVs/6m/entry_pages.csv
+++ b/test/plausible_web/controllers/CSVs/6m/entry_pages.csv
@@ -1,3 +1,3 @@
-name,unique_entrances,total_entrances,visit_duration
-/,4,4,15
-/signup,1,1,60
+name,unique_entrances,total_entrances,bounce_rate,visit_duration
+/,4,4,75,15
+/signup,1,1,0,60
diff --git a/test/plausible_web/controllers/api/stats_controller/pages_test.exs b/test/plausible_web/controllers/api/stats_controller/pages_test.exs
index 559036ccd0..f595a30395 100644
--- a/test/plausible_web/controllers/api/stats_controller/pages_test.exs
+++ b/test/plausible_web/controllers/api/stats_controller/pages_test.exs
@@ -2185,13 +2185,15 @@ defmodule PlausibleWeb.Api.StatsController.PagesTest do
"visitors" => 2,
"visits" => 2,
"name" => "/page1",
- "visit_duration" => 0
+ "visit_duration" => 0,
+ "bounce_rate" => 100
},
%{
"visitors" => 1,
"visits" => 2,
"name" => "/page2",
- "visit_duration" => 450
+ "visit_duration" => 450,
+ "bounce_rate" => 50
}
]
end
@@ -2241,13 +2243,15 @@ defmodule PlausibleWeb.Api.StatsController.PagesTest do
"visitors" => 1,
"visits" => 1,
"name" => "/blog",
- "visit_duration" => 60
+ "visit_duration" => 60,
+ "bounce_rate" => 0
},
%{
"visitors" => 1,
"visits" => 1,
"name" => "/blog/john-2",
- "visit_duration" => 0
+ "visit_duration" => 0,
+ "bounce_rate" => 100
}
]
end
@@ -2296,13 +2300,15 @@ defmodule PlausibleWeb.Api.StatsController.PagesTest do
"visitors" => 2,
"visits" => 2,
"name" => "/page1",
- "visit_duration" => 0
+ "visit_duration" => 0,
+ "bounce_rate" => 100
},
%{
"visitors" => 1,
"visits" => 2,
"name" => "/page2",
- "visit_duration" => 450
+ "visit_duration" => 450,
+ "bounce_rate" => 50
}
]
@@ -2317,13 +2323,15 @@ defmodule PlausibleWeb.Api.StatsController.PagesTest do
"visitors" => 3,
"visits" => 5,
"name" => "/page2",
- "visit_duration" => 240.0
+ "visit_duration" => 240.0,
+ "bounce_rate" => 20
},
%{
"visitors" => 2,
"visits" => 2,
"name" => "/page1",
- "visit_duration" => 0
+ "visit_duration" => 0,
+ "bounce_rate" => 100
}
]
end
@@ -2376,8 +2384,20 @@ defmodule PlausibleWeb.Api.StatsController.PagesTest do
# We're going to only join sessions where the exit hostname matches the filter
assert json_response(conn, 200)["results"] == [
- %{"name" => "/page1", "visit_duration" => 0, "visitors" => 1, "visits" => 1},
- %{"name" => "/page2", "visit_duration" => 0, "visitors" => 1, "visits" => 1}
+ %{
+ "name" => "/page1",
+ "visit_duration" => 0,
+ "visitors" => 1,
+ "visits" => 1,
+ "bounce_rate" => 100
+ },
+ %{
+ "name" => "/page2",
+ "visit_duration" => 0,
+ "visitors" => 1,
+ "visits" => 1,
+ "bounce_rate" => 100
+ }
]
end
@@ -2534,19 +2554,22 @@ defmodule PlausibleWeb.Api.StatsController.PagesTest do
"visit_duration" => 100.0,
"name" => "/a",
"visits" => 10,
- "visitors" => 6
+ "visitors" => 6,
+ "bounce_rate" => 10
},
%{
"visit_duration" => 50.0,
"name" => "/bbb",
"visits" => 2,
- "visitors" => 2
+ "visitors" => 2,
+ "bounce_rate" => 0
},
%{
"visit_duration" => 0,
"name" => "/aaa",
"visits" => 1,
- "visitors" => 1
+ "visitors" => 1,
+ "bounce_rate" => 100
}
]
end
diff --git a/test/plausible_web/controllers/stats_controller_test.exs b/test/plausible_web/controllers/stats_controller_test.exs
index f3a21b9032..90c3273bde 100644
--- a/test/plausible_web/controllers/stats_controller_test.exs
+++ b/test/plausible_web/controllers/stats_controller_test.exs
@@ -751,8 +751,14 @@ defmodule PlausibleWeb.StatsControllerTest do
{~c"entry_pages.csv", data} ->
assert parse_csv(data) == [
- ["name", "unique_entrances", "total_entrances", "visit_duration"],
- ["/test", "1", "1", "10.0"],
+ [
+ "name",
+ "unique_entrances",
+ "total_entrances",
+ "bounce_rate",
+ "visit_duration"
+ ],
+ ["/test", "1", "1", "0.0", "10.0"],
[""]
]