Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Proposal: Remove `unique users` from dashboard when filtering by goal (#4999)
Karl-Aksel Puulmann4c68010dd923
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 85d597ad51..59d7b2ca71 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.### Removed- Internal stats API routes no longer support legacy dashboard filter format.+- Dashboard no longer shows "Unique visitors" in top stats when filtering by a goal which used to count all users including ones who didn't complete the goal. "Unique conversions" shows the number of unique visitors who completed the goal.### Changeddiff --git a/lib/plausible_web/controllers/api/stats_controller.ex b/lib/plausible_web/controllers/api/stats_controller.exindex 158da790e9..a4a279ed45 100644--- a/lib/plausible_web/controllers/api/stats_controller.ex+++ b/lib/plausible_web/controllers/api/stats_controller.ex@@ -364,13 +364,12 @@ defmodule PlausibleWeb.Api.StatsController dodefp fetch_goal_top_stats(site, query) dometrics =- [:total_visitors, :visitors, :events, :conversion_rate] ++ @revenue_metrics+ [:visitors, :events, :conversion_rate] ++ @revenue_metrics%{results: results, meta: meta} = Stats.aggregate(site, query, metrics)top_stats =[- top_stats_entry(results, "Unique visitors", :total_visitors),top_stats_entry(results, "Unique conversions", :visitors),top_stats_entry(results, "Total conversions", :events),on_ee dodiff --git a/test/plausible_web/controllers/api/stats_controller/top_stats_test.exs b/test/plausible_web/controllers/api/stats_controller/top_stats_test.exsindex ebc7252684..f9336b5b6a 100644--- a/test/plausible_web/controllers/api/stats_controller/top_stats_test.exs+++ b/test/plausible_web/controllers/api/stats_controller/top_stats_test.exs@@ -916,13 +916,12 @@ defmodule PlausibleWeb.Api.StatsController.TopStatsTest do} dofilters = Jason.encode!([[:is, "event:goal", ["Signup"]]])- [unique_visitors, unique_conversions, total_conversions, cr] =+ [unique_conversions, total_conversions, cr] =conn|> get("/api/stats/#{site.domain}/top-stats?filters=#{filters}")|> json_response(200)|> Map.get("top_stats")- assert %{"graph_metric" => "total_visitors"} = unique_visitorsassert %{"graph_metric" => "visitors"} = unique_conversionsassert %{"graph_metric" => "events"} = total_conversionsassert %{"graph_metric" => "conversion_rate"} = cr@@ -1307,12 +1306,16 @@ defmodule PlausibleWeb.Api.StatsController.TopStatsTest dodescribe "GET /api/stats/top-stats - filtered for goal" dosetup [:create_user, :log_in, :create_site]- test "returns total unique visitors", %{conn: conn, site: site} do+ test "returns total and unique conversions", %{conn: conn, site: site} do+ insert(:goal, site: site, event_name: "Signup")+populate_stats(site, [build(:pageview, user_id: @user_id),build(:pageview, user_id: @user_id),build(:pageview),- build(:event, name: "Signup")+ build(:event, user_id: 1, name: "Signup"),+ build(:event, user_id: 1, name: "Signup"),+ build(:event, user_id: 2, name: "Signup")])filters = Jason.encode!([[:is, "event:goal", ["Signup"]]])@@ -1325,7 +1328,11 @@ defmodule PlausibleWeb.Api.StatsController.TopStatsTest dores = json_response(conn, 200)- assert %{"name" => "Unique visitors", "value" => 3, "graph_metric" => "total_visitors"} in res[+ assert %{"name" => "Unique conversions", "value" => 2, "graph_metric" => "visitors"} in res[+ "top_stats"+ ]++ assert %{"name" => "Total conversions", "value" => 3, "graph_metric" => "events"} in res["top_stats"]end