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): add acquisition overview to the new dashboard (#99176)

Javier Bahamondes6e8a4685387d
diff --git a/docs/internal/marketing-analytics-configuration-writes.md b/docs/internal/marketing-analytics-configuration-writes.md
index a3244e4210c0..a20c96914df4 100644
--- a/docs/internal/marketing-analytics-configuration-writes.md
+++ b/docs/internal/marketing-analytics-configuration-writes.md
@@ -13,3 +13,7 @@ Suggestion review, dismissal, restoration, batch review, capability filters, res
`marketing analytics setup change submitted`, `change completed` and `change failed` share the same prefix and report operation types, counts, source and whether the change is an undo. Completed reports the server's applied count, which may be zero.
`marketing analytics setup sync retry completed` reports requested and failed counts; it measures scheduling retries, not completed syncs.
Payloads exclude suggestion IDs, titles, evidence, goal names and UTM values. Source navigation measures entry into connection flows; existing warehouse connection events measure their completion.
+
+## Acquisition preview
+
+With `new-marketing-analytics-dashboard` enabled, the dashboard shows visitors, sessions and pageviews using the existing Web Overview query and metric cards. The date range, comparison and saved test-account filter apply to both the summary and channel table. Reload summary refreshes only the summary. The legacy dashboard remains available when the flag is off.
diff --git a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx
index 21b6659f393b..d5f90aa099dd 100644
--- a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx
+++ b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx
@@ -1,13 +1,25 @@
+import { useActions, useValues } from 'kea'
+
+import { LemonBanner, LemonButton } from '@posthog/lemon-ui'
+
+import { CompareFilter } from 'lib/components/CompareFilter/CompareFilter'
+import { DateFilter } from 'lib/components/DateFilter/DateFilter'
import { MARKETING_ANALYTICS_DEFAULT_QUERY_TAGS } from 'scenes/web-analytics/common'
+import { marketingAnalyticsLogic } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic'
import { MarketingAnalyticsCell } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/shared'
import { webAnalyticsDataTableQueryContext } from 'scenes/web-analytics/tiles/WebAnalyticsTile'
+import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'
+import { OverviewMetricCardGrid } from '~/queries/nodes/OverviewGrid/OverviewMetricCardGrid'
+import { labelFromKey } from '~/queries/nodes/WebOverview/WebOverview'
import { Query } from '~/queries/Query/Query'
import {
DataTableNode,
MarketingAnalyticsBaseColumns,
MarketingAnalyticsDrillDownLevel,
NodeKind,
+ WebOverviewQuery,
+ WebOverviewQueryResponse,
} from '~/queries/schema/schema-general'
import { QueryContext, QueryContextColumn } from '~/queries/types'
@@ -67,9 +79,62 @@ const QUERY_CONTEXT: QueryContext = {
// Scaffold for the redesigned marketing analytics dashboard, gated behind the
// `new-marketing-analytics-dashboard` feature flag.
export function NewMarketingAnalyticsDashboard(): JSX.Element {
+ const { dateFilter, compareFilter, shouldFilterTestAccounts } = useValues(marketingAnalyticsLogic)
+ const { setDates, setCompareFilter } = useActions(marketingAnalyticsLogic)
+ const dateRange = { date_from: dateFilter.dateFrom, date_to: dateFilter.dateTo }
+ const query: WebOverviewQuery = {
+ kind: NodeKind.WebOverviewQuery,
+ dateRange,
+ compareFilter,
+ filterTestAccounts: shouldFilterTestAccounts,
+ properties: [],
+ tags: MARKETING_ANALYTICS_DEFAULT_QUERY_TAGS,
+ }
+ const overviewLogic = dataNodeLogic({ query, key: 'marketing-acquisition-overview' })
+ const { response, responseLoading, responseError } = useValues(overviewLogic)
+ const { loadData } = useActions(overviewLogic)
+ const overview = response as WebOverviewQueryResponse | undefined
+ const items = ['visitors', 'sessions', 'views'].flatMap((key) =>
+ (overview?.results?.filter((item) => item.key === key) ?? []).map((item) => ({ ...item, value: item.value }))
+ )
+
return (
- <div className="mt-4">
- <Query query={CHANNEL_SOURCE_BREAKDOWN} context={QUERY_CONTEXT} readOnly />
+ <div className="mt-4 flex flex-col gap-4">
+ <div className="flex flex-wrap items-center gap-2">
+ <DateFilter dateFrom={dateFilter.dateFrom} dateTo={dateFilter.dateTo} onChange={setDates} />
+ <CompareFilter compareFilter={compareFilter} updateCompareFilter={setCompareFilter} />
+ <LemonButton size="small" loading={responseLoading} onClick={() => loadData('force_async')}>
+ Reload summary
+ </LemonButton>
+ </div>
+ <h2 className="mb-0">Acquisition</h2>
+ {responseError ? (
+ <LemonBanner type="error" action={{ children: 'Retry', onClick: () => loadData('force_async') }}>
+ Could not load acquisition metrics. Try again.
+ </LemonBanner>
+ ) : (
+ <OverviewMetricCardGrid
+ items={items}
+ loading={responseLoading}
+ numSkeletons={3}
+ samplingRate={overview?.samplingRate}
+ preComputeStrategy={overview?.preComputeStrategy}
+ labelFromKey={labelFromKey}
+ />
+ )}
+ <Query
+ query={{
+ ...CHANNEL_SOURCE_BREAKDOWN,
+ source: {
+ ...CHANNEL_SOURCE_BREAKDOWN.source,
+ dateRange,
+ compareFilter,
+ filterTestAccounts: shouldFilterTestAccounts,
+ },
+ }}
+ context={QUERY_CONTEXT}
+ readOnly
+ />
</div>
)
}