Skip to content

Commit

Permalink
Allow querying events and pageviews from sessions table
Browse files Browse the repository at this point in the history
This is not strictly accurate, especially with shorter time frames, but
is useful for a fallback mechanism. I'll figure out something around
shorter time frames in the future.

See also: #4292
  • Loading branch information
macobo committed Jul 1, 2024
1 parent f54d6d2 commit 9a769a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/plausible/stats/table_decider.ex
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ defmodule Plausible.Stats.TableDecider do
defp metric_partitioner(%Query{v2: true}, :group_conversion_rate), do: :either
defp metric_partitioner(%Query{v2: true}, :visitors), do: :either
defp metric_partitioner(%Query{v2: true}, :visits), do: :either
# Note: These are not very accurate on shorter time ranges
defp metric_partitioner(%Query{v2: true}, :pageviews), do: :either
defp metric_partitioner(%Query{v2: true}, :events), do: :either

defp metric_partitioner(_, :conversion_rate), do: :event
defp metric_partitioner(_, :group_conversion_rate), do: :event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ defmodule PlausibleWeb.Api.ExternalStatsController.BreakdownTest do
"period" => "day",
"date" => "2021-01-01",
"property" => "visit:exit_page",
"metrics" => "visitors,visits,bounce_rate,visit_duration",
"metrics" => "visitors,visits,bounce_rate,visit_duration,events,pageviews",
"with_imported" => "true"
})

Expand All @@ -1034,14 +1034,18 @@ defmodule PlausibleWeb.Api.ExternalStatsController.BreakdownTest do
"exit_page" => "/b",
"visit_duration" => 150.0,
"visitors" => 3,
"visits" => 4
"visits" => 4,
"events" => 7,
"pageviews" => 7
},
%{
"bounce_rate" => 100.0,
"exit_page" => "/a",
"visit_duration" => 0.0,
"visitors" => 1,
"visits" => 1
"visits" => 1,
"events" => 1,
"pageviews" => 1
}
]
}
Expand Down

0 comments on commit 9a769a9

Please sign in to comment.