:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(funnels): display aggregate conversion rate in breakdown tooltips (#65872)
Kyle Swank285fac9cfa99
diff --git a/frontend/src/scenes/funnels/FunnelTooltip.tsx b/frontend/src/scenes/funnels/FunnelTooltip.tsxindex 63d455a72524..1a084c891921 100644--- a/frontend/src/scenes/funnels/FunnelTooltip.tsx+++ b/frontend/src/scenes/funnels/FunnelTooltip.tsx@@ -36,6 +36,8 @@ export interface FunnelTooltipProps {embedded?: boolean/** Date range of the hovered series' compare period; shown when the series is compare-tagged. */comparePeriodDateRange?: string | null+ /** Baseline conversion rate across all breakdown values; shown only for breakdown variants past the first step. */+ aggregateConversionRate?: number | null}export function FunnelTooltip({@@ -46,6 +48,7 @@ export function FunnelTooltip({breakdownFilter,embedded = false,comparePeriodDateRange,+ aggregateConversionRate,}: FunnelTooltipProps): JSX.Element {const { allCohorts } = useValues(cohortsModel)const { formatPropertyValueForDisplay } = useValues(propertyDefinitionsModel)@@ -96,6 +99,12 @@ export function FunnelTooltip({<td>Conversion so far</td><td>{percentage(series.conversionRates.total, 2, true)}</td></tr>+ {stepIndex > 0 && aggregateConversionRate != null && (+ <tr>+ <td>Baseline conversion rate</td>+ <td>{percentage(aggregateConversionRate, 2, true)}</td>+ </tr>+ )}{stepIndex > 0 && (<tr><td>Conversion from previous</td>diff --git a/frontend/src/scenes/funnels/funnelUtils.tsx b/frontend/src/scenes/funnels/funnelUtils.tsxindex ef6ebc3e6052..171c6623f7f4 100644--- a/frontend/src/scenes/funnels/funnelUtils.tsx+++ b/frontend/src/scenes/funnels/funnelUtils.tsx@@ -386,6 +386,21 @@ export function hasBreakdown(breakdownValue: BreakdownKeyType | undefined): bool)}+/**+ * Aggregate "conversion so far" (across all breakdown values) to show alongside a hovered breakdown+ * variant's own conversion. Returns null unless `series` is a genuine breakdown variant of `step` —+ * excluding the top-level step itself, compare-only bars, and breakdown+compare (the aggregate spans+ * periods there and would be ambiguous).+ */+export function getFunnelAggregateConversionRate(+ series: FunnelStepWithConversionMetrics,+ step: FunnelStepWithConversionMetrics+): number | null {+ return series !== step && hasBreakdown(series.breakdown_value) && !series.compare_label+ ? step.conversionRates.total+ : null+}+/** String identifier for breakdowns used when determining visibility. */export function getVisibilityKey(breakdownValue?: BreakdownKeyType): string {const breakdownValues = getBreakdownStepValues(diff --git a/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/FunnelBarHorizontalTooltip.tsx b/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/FunnelBarHorizontalTooltip.tsxindex f51cf6528548..96ee75f81766 100644--- a/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/FunnelBarHorizontalTooltip.tsx+++ b/products/product_analytics/frontend/insights/funnels/FunnelBarHorizontalChart/FunnelBarHorizontalTooltip.tsx@@ -1,7 +1,7 @@import type { TooltipContext } from '@posthog/quill-charts'import { FunnelTooltip } from 'scenes/funnels/FunnelTooltip'-import { funnelComparePeriodDateRange } from 'scenes/funnels/funnelUtils'+import { funnelComparePeriodDateRange, getFunnelAggregateConversionRate } from 'scenes/funnels/funnelUtils'import type { BreakdownFilter } from '~/queries/schema/schema-general'import type { FunnelStepWithConversionMetrics } from '~/types'@@ -37,6 +37,7 @@ export function FunnelBarHorizontalTooltip({const breakdownIndex = entry.series.meta?.breakdownIndexconst series =breakdownIndex != null && step.nested_breakdown?.[breakdownIndex] ? step.nested_breakdown[breakdownIndex] : step+ const aggregateConversionRate = getFunnelAggregateConversionRate(series, step)return (<FunnelTooltip@@ -45,6 +46,7 @@ export function FunnelBarHorizontalTooltip({series={series}groupTypeLabel={groupTypeLabel}breakdownFilter={breakdownFilter}+ aggregateConversionRate={aggregateConversionRate}comparePeriodDateRange={series.compare_label? funnelComparePeriodDateRange(series.compare_label, resolvedDateRange, compareTo)diff --git a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarTooltip.tsx b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarTooltip.tsxindex 75ae1d75a941..164cf36d30e1 100644--- a/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarTooltip.tsx+++ b/products/product_analytics/frontend/insights/funnels/FunnelStepsBarChart/FunnelStepsBarTooltip.tsx@@ -1,7 +1,7 @@import type { TooltipContext } from '@posthog/quill-charts'import { FunnelTooltip } from 'scenes/funnels/FunnelTooltip'-import { funnelComparePeriodDateRange } from 'scenes/funnels/funnelUtils'+import { funnelComparePeriodDateRange, getFunnelAggregateConversionRate } from 'scenes/funnels/funnelUtils'import type { BreakdownFilter } from '~/queries/schema/schema-general'import type { FunnelStepWithConversionMetrics } from '~/types'@@ -36,6 +36,7 @@ export function FunnelStepsBarTooltip({const breakdownIndex = entry.series.meta?.breakdownIndex ?? 0const series = step.nested_breakdown?.[breakdownIndex] ?? step+ const aggregateConversionRate = getFunnelAggregateConversionRate(series, step)return (<FunnelTooltip@@ -44,6 +45,7 @@ export function FunnelStepsBarTooltip({series={series}groupTypeLabel={groupTypeLabel}breakdownFilter={breakdownFilter}+ aggregateConversionRate={aggregateConversionRate}comparePeriodDateRange={series.compare_label? funnelComparePeriodDateRange(series.compare_label, resolvedDateRange, compareTo)