Skip to content

: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.

feat(marketing): show retention in the new dashboard (#99218)

Javier Bahamondes081f3dbb2fc3
diff --git a/docs/internal/marketing-analytics-configuration-writes.md b/docs/internal/marketing-analytics-configuration-writes.md
index d3ef1525cc20..6e8031714696 100644
--- a/docs/internal/marketing-analytics-configuration-writes.md
+++ b/docs/internal/marketing-analytics-configuration-writes.md
@@ -25,3 +25,5 @@ Revenue ranks rows by their highest attributed value across models before the se
Engagement displays session duration and bounce rate from the same Web Overview response as Acquisition. Both sections share date, comparison and test-account filters; rendering Engagement adds no extra query.
The new dashboard embeds the existing Attribution explorer as Conversion when `marketing-analytics-attribution` is enabled. It keeps goal selection, attribution models, conversion paths and the explorer’s date and test-account filters.
+
+The new dashboard also embeds the existing Retention explorer when `marketing-analytics-retention` is enabled. It shares the acquisition date range and keeps the explorer’s cohort controls, reload and empty state. Previous-period comparison and the traffic test-account filter do not apply to Retention.
diff --git a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsx b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsx
new file mode 100644
index 000000000000..52fec458df64
--- /dev/null
+++ b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsx
@@ -0,0 +1,66 @@
+import { cleanup, render, screen } from '@testing-library/react'
+import { useValues } from 'kea'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+
+import { NewMarketingAnalyticsDashboard } from './NewMarketingAnalyticsDashboard'
+
+jest.mock('kea', () => ({ ...jest.requireActual('kea'), useValues: jest.fn(), useActions: () => ({}) }))
+jest.mock('@posthog/lemon-ui', () => ({ LemonBanner: () => null, LemonButton: () => null, LemonSkeleton: () => null }))
+jest.mock('lib/components/CompareFilter/CompareFilter', () => ({ CompareFilter: () => null }))
+jest.mock('lib/components/DateFilter/DateFilter', () => ({ DateFilter: () => null }))
+jest.mock('lib/logic/featureFlagLogic', () => ({ featureFlagLogic: {} }))
+jest.mock('scenes/web-analytics/common', () => ({ MARKETING_ANALYTICS_DEFAULT_QUERY_TAGS: {} }))
+jest.mock('scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic', () => ({
+ marketingAnalyticsLogic: {},
+}))
+jest.mock('scenes/web-analytics/tabs/marketing-analytics/frontend/shared', () => ({
+ MarketingAnalyticsCell: () => null,
+}))
+jest.mock('scenes/web-analytics/tiles/WebAnalyticsTile', () => ({ webAnalyticsDataTableQueryContext: {} }))
+jest.mock('~/queries/nodes/DataNode/dataNodeLogic', () => ({ dataNodeLogic: () => ({}) }))
+jest.mock('~/queries/nodes/OverviewGrid/OverviewMetricCardGrid', () => ({ OverviewMetricCardGrid: () => null }))
+jest.mock('~/queries/nodes/WebOverview/WebOverview', () => ({ labelFromKey: () => '' }))
+jest.mock('~/queries/Query/Query', () => ({ Query: () => null }))
+jest.mock('scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionTab', () => ({
+ AttributionTab: () => <div>Attribution explorer</div>,
+}))
+jest.mock('scenes/teamLogic', () => ({ teamLogic: {} }))
+jest.mock('scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAttributionLogic', () => ({
+ marketingAttributionLogic: {},
+}))
+jest.mock('scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionTable', () => ({
+ AttributionTable: () => null,
+}))
+jest.mock('scenes/web-analytics/tabs/marketing-analytics/frontend/components/RetentionTab/RetentionTab', () => ({
+ RetentionTab: () => <div>Retention explorer</div>,
+}))
+
+describe('NewMarketingAnalyticsDashboard', () => {
+ afterEach(cleanup)
+
+ it.each([
+ [false, false],
+ [true, false],
+ [false, true],
+ [true, true],
+ ])('keeps conversion (%s) and retention (%s) independently gated alongside traffic', (conversion, retention) => {
+ jest.mocked(useValues).mockReturnValue({
+ featureFlags: {
+ [FEATURE_FLAGS.MARKETING_ANALYTICS_ATTRIBUTION]: conversion,
+ [FEATURE_FLAGS.MARKETING_ANALYTICS_RETENTION]: retention,
+ },
+ dateFilter: { dateFrom: '-30d', dateTo: null },
+ compareFilter: { compare: false },
+ shouldFilterTestAccounts: false,
+ responseLoading: false,
+ })
+
+ render(<NewMarketingAnalyticsDashboard />)
+
+ expect(screen.getByText('Acquisition')).not.toBeNull()
+ expect(screen.getByText('Engagement')).not.toBeNull()
+ expect(screen.queryByText('Attribution explorer') !== null).toBe(conversion)
+ expect(screen.queryByText('Retention explorer') !== null).toBe(retention)
+ })
+})
diff --git a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx
index 22c1f4b2671d..61f717844cfa 100644
--- a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx
+++ b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx
@@ -10,6 +10,7 @@ import { teamLogic } from 'scenes/teamLogic'
import { MARKETING_ANALYTICS_DEFAULT_QUERY_TAGS } from 'scenes/web-analytics/common'
import { AttributionTab } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionTab'
import { AttributionTable } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionTable'
+import { RetentionTab } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/components/RetentionTab/RetentionTab'
import {
MarketingAnalyticsTab,
SetupSection,
@@ -153,6 +154,15 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {
<AttributionTab />
</section>
)}
+ {featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_RETENTION] && (
+ <section aria-label="Retention" className="flex flex-col gap-2">
+ <h2 className="mb-0">Retention</h2>
+ <p className="text-secondary mb-0">
+ Follow visitors acquired in the selected date range across subsequent periods.
+ </p>
+ <RetentionTab />
+ </section>
+ )}
{featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_ATTRIBUTION] && (
<section aria-label="Revenue" className="flex flex-col gap-4">
<h2 className="mb-0">Revenue</h2>