: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(marketing): compact dashboard navigation and traffic layout (#101043)
Javier Bahamondes393f7d960345
diff --git a/docs/internal/marketing-analytics-compact-dashboard.md b/docs/internal/marketing-analytics-compact-dashboard.mdnew file mode 100644index 000000000000..c1e8b69b960f--- /dev/null+++ b/docs/internal/marketing-analytics-compact-dashboard.md@@ -0,0 +1,13 @@+# Compact marketing dashboard++The `new-marketing-analytics-dashboard` preview uses a compact section selector. The selected traffic section shows its description once above the metrics. Buttons wrap when the scene narrows, including when a side panel is open.++Source and conversion-goal suggestions start collapsed for new preferences. Existing expansion preferences remain respected. Both notices retain their review and setup actions.++Acquisition keeps visitors, sessions, pageviews, new customers and the customer-to-visitor ratio. Customer goal selection, comparison periods and breakdown sorting retain their existing behavior.++The full-width Acquisition trend shows total visitors using pageview and screen events. The breakdown selector only groups the table below it; it does not filter the trend or overview cards. Channel, UTM source, referring domain, campaign, medium and landing page remain separate options. The table retains customer metrics when a customer goal is configured.++Retention, conversion and revenue retain their existing controls and feature flags. Conversion displays its section description below the heading.++With the new dashboard enabled, top-level navigation contains Dashboard, Ad performance and Setup. Attribution explorer and Retention explorer remain available in the legacy dashboard only. Existing explorer tab URLs fall back to Dashboard in the new layout. Conversion and Retention remain accessible through the dashboard section selector, subject to their existing feature flags.diff --git a/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx b/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsxindex d9ad81dd8930..deabcd89c613 100644--- a/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx+++ b/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx@@ -300,10 +300,8 @@ const MarketingAnalyticsContent = (): JSX.Element => {},]: []),- // Untouched by Setup: the explorer compares attribution models against each- // other, which is analysis. Setup's Attribution section is the two config- // fields (mode and lookback), which is a different thing with the same name.- ...(featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_ATTRIBUTION]+ ...(!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_NEW_DASHBOARD] &&+ featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_ATTRIBUTION]? [{key: MarketingAnalyticsTab.ATTRIBUTION,@@ -312,7 +310,8 @@ const MarketingAnalyticsContent = (): JSX.Element => {},]: []),- ...(featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_RETENTION]+ ...(!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_NEW_DASHBOARD] &&+ featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_RETENTION]? [{key: MarketingAnalyticsTab.RETENTION,diff --git a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.goals.test.tsx b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.goals.test.tsxindex 2a8285a65fc5..0bd7be52ed64 100644--- a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.goals.test.tsx+++ b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.goals.test.tsx@@ -59,6 +59,14 @@ describe('Dashboard goal suggestions', () => {const unmountSetup = setupPlanLogic.mount()const view = render(<NewMarketingAnalyticsDashboard />)try {+ await screen.findByText('Suggested conversion goals (1)')+ expect(+ screen+ .getByText('Suggested conversion goals (1)')+ .closest('[aria-expanded]')+ ?.getAttribute('aria-expanded')+ ).toBe('false')+ fireEvent.click(screen.getByText('Suggested conversion goals (1)'))await screen.findByText('Mark a revenue goal')fireEvent.click(screen.getByText('Suggested conversion goals (1)'))expect(localStorage.getItem('marketing-goal-suggestions-expanded')).toBe('false')diff --git a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.sources.test.tsx b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.sources.test.tsxindex 1059b645428f..c2d32b084e19 100644--- a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.sources.test.tsx+++ b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.sources.test.tsx@@ -54,6 +54,11 @@ it('reuses source suggestions, remembers collapse and opens their review in Setuconst unmountSetup = setupPlanLogic.mount()const view = render(<NewMarketingAnalyticsDashboard />)try {+ await screen.findByText('Suggested ad sources (1)')+ expect(+ screen.getByText('Suggested ad sources (1)').closest('[aria-expanded]')?.getAttribute('aria-expanded')+ ).toBe('false')+ fireEvent.click(screen.getByText('Suggested ad sources (1)'))await screen.findByText('Connect Google Ads')fireEvent.click(screen.getByText('Suggested ad sources (1)'))expect(localStorage.getItem('marketing-source-suggestions-expanded')).toBe('false')diff --git a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsx b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsxindex a4ad6713da17..26ac5a266798 100644--- a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsx+++ b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsx@@ -61,7 +61,9 @@ 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: ({ query }: { query: unknown }) => <div data-attr="traffic-query">{JSON.stringify(query)}</div>,+ Query: ({ query }: { query: { kind: string } }) => (+ <div data-attr={query.kind === 'DataTableNode' ? 'traffic-query' : 'trend-query'}>{JSON.stringify(query)}</div>+ ),}))jest.mock('scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionTab', () => ({AttributionTab: () => <div>Attribution explorer</div>,@@ -110,6 +112,7 @@ describe('NewMarketingAnalyticsDashboard', () => {expect(screen.getByText('Engagement')).not.toBeNull()expect(screen.queryByText('Attribution explorer')).toBeNull()expect(screen.queryByText('Retention explorer')).toBeNull()+ const trendBeforeBreakdown = screen.getByTestId('trend-query').textContentfireEvent.change(screen.getByLabelText('Traffic breakdown'), { target: { value: 'InitialUTMCampaign' } })expect(JSON.parse(screen.getByTestId('traffic-query').textContent || '{}').source).toMatchObject({kind: 'WebStatsTableQuery',@@ -118,6 +121,7 @@ describe('NewMarketingAnalyticsDashboard', () => {dateRange: { date_from: '-30d', date_to: null },compareFilter: { compare: false },})+ expect(screen.getByTestId('trend-query').textContent).toBe(trendBeforeBreakdown)fireEvent.click(screen.getByText('Engagement'))expect(JSON.parse(screen.getByTestId('traffic-query').textContent || '{}')).toMatchObject({hiddenColumns: ['context.columns.views'],diff --git a/products/marketing_analytics/frontend/dashboard/NewMarketingAnalyticsDashboard.tsx b/products/marketing_analytics/frontend/dashboard/NewMarketingAnalyticsDashboard.tsxindex 3fa4d0a2ab0a..9b42a2adf218 100644--- a/products/marketing_analytics/frontend/dashboard/NewMarketingAnalyticsDashboard.tsx+++ b/products/marketing_analytics/frontend/dashboard/NewMarketingAnalyticsDashboard.tsx@@ -2,7 +2,7 @@ import { useActions, useValues } from 'kea'import { useEffect, useRef, useState } from 'react'import { IconCursor, IconPeople, IconRetention, IconTarget, IconTrends } from '@posthog/icons'-import { LemonBanner, LemonButton, LemonCollapse, LemonSelect, LemonSkeleton } from '@posthog/lemon-ui'+import { LemonBanner, LemonButton, LemonCard, LemonCollapse, LemonSelect, LemonSkeleton } from '@posthog/lemon-ui'import { CompareFilter } from 'lib/components/CompareFilter/CompareFilter'import { DateFilter } from 'lib/components/DateFilter/DateFilter'@@ -36,6 +36,7 @@ import {WebOverviewQueryResponse,WebStatsBreakdown,} from '~/queries/schema/schema-general'+import { BaseMathType, ChartDisplayType, PropertyFilterType, PropertyOperator } from '~/types'import { CustomerAcquisitionCards } from './CustomerAcquisitionCards'import { marketingAcquisitionLogic } from './marketingAcquisitionLogic'@@ -108,14 +109,14 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {const { setDates, setCompareFilter, setActiveTab, setSetupSection } = useActions(marketingAnalyticsLogic)const { setupPlan, setupPlanLoading, visibleSuggestions } = useValues(setupPlanLogic)const { loadSetupPlan, reviewSuggestion } = useActions(setupPlanLogic)- const [sourcesExpanded, setSourcesExpanded] = useLocalStorage('marketing-source-suggestions-expanded', true)+ const [sourcesExpanded, setSourcesExpanded] = useLocalStorage('marketing-source-suggestions-expanded', false)const sourceSuggestions = visibleSuggestions.filter((suggestion) => suggestion.kind === 'connect_source')const reviewSources = (): void => {setSetupSection(SetupSection.SOURCES)setActiveTab(MarketingAnalyticsTab.SETUP)}- const [goalsExpanded, setGoalsExpanded] = useLocalStorage('marketing-goal-suggestions-expanded', true)+ const [goalsExpanded, setGoalsExpanded] = useLocalStorage('marketing-goal-suggestions-expanded', false)const goalSuggestions = suggestionsForSection(visibleSuggestions, SetupSection.CONVERSION_GOALS)const reviewGoals = (): void => {setSetupSection(SetupSection.CONVERSION_GOALS)@@ -185,90 +186,89 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {</>)}</div>- {sourceSuggestions.length > 0 && (- <div className="border rounded relative">- <LemonButton className="absolute right-2 top-0 z-10" size="small" onClick={reviewSources}>- Review in Setup- </LemonButton>- <LemonCollapse- embedded- size="small"- activeKey={sourcesExpanded ? 'sources' : null}- onChange={(key) => setSourcesExpanded(key !== null)}- panels={[- {- key: 'sources',- header: {- children: `Suggested ad sources (${sourceSuggestions.length})`,- className: 'pr-36',+ <div className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,24rem),1fr))] items-start gap-2 empty:hidden">+ {sourceSuggestions.length > 0 && (+ <div className="border rounded relative">+ <LemonButton className="absolute right-2 top-0 z-10" size="small" onClick={reviewSources}>+ Review in Setup+ </LemonButton>+ <LemonCollapse+ embedded+ size="small"+ activeKey={sourcesExpanded ? 'sources' : null}+ onChange={(key) => setSourcesExpanded(key !== null)}+ panels={[+ {+ key: 'sources',+ header: {+ children: `Suggested ad sources (${sourceSuggestions.length})`,+ className: 'pr-36',+ },+ content: sourceSuggestions.map((suggestion) => (+ <SuggestionRow+ key={suggestion.id}+ suggestion={suggestion}+ currentSection={SetupSection.SOURCES}+ onReview={(item) => {+ reviewSources()+ reviewSuggestion(item)+ }}+ />+ )),},- content: sourceSuggestions.map((suggestion) => (- <SuggestionRow- key={suggestion.id}- suggestion={suggestion}- currentSection={SetupSection.SOURCES}- onReview={(item) => {- reviewSources()- reviewSuggestion(item)- }}- />- )),- },- ]}- />- </div>- )}- {goalSuggestions.length > 0 && (- <div className="border rounded relative">- <LemonButton className="absolute right-2 top-0 z-10" size="small" onClick={reviewGoals}>- Review in Setup- </LemonButton>- <LemonCollapse- embedded- size="small"- activeKey={goalsExpanded ? 'goals' : null}- onChange={(key) => setGoalsExpanded(key !== null)}- panels={[- {- key: 'goals',- header: {- children: `Suggested conversion goals (${goalSuggestions.length})`,- className: 'pr-36',+ ]}+ />+ </div>+ )}+ {goalSuggestions.length > 0 && (+ <div className="border rounded relative">+ <LemonButton className="absolute right-2 top-0 z-10" size="small" onClick={reviewGoals}>+ Review in Setup+ </LemonButton>+ <LemonCollapse+ embedded+ size="small"+ activeKey={goalsExpanded ? 'goals' : null}+ onChange={(key) => setGoalsExpanded(key !== null)}+ panels={[+ {+ key: 'goals',+ header: {+ children: `Suggested conversion goals (${goalSuggestions.length})`,+ className: 'pr-36',+ },+ content: goalSuggestions.map((suggestion) => (+ <SuggestionRow+ key={suggestion.id}+ suggestion={suggestion}+ currentSection={SetupSection.CONVERSION_GOALS}+ onReview={(item) => {+ reviewGoals()+ reviewSuggestion(item)+ }}+ />+ )),},- content: goalSuggestions.map((suggestion) => (- <SuggestionRow- key={suggestion.id}- suggestion={suggestion}- currentSection={SetupSection.CONVERSION_GOALS}- onReview={(item) => {- reviewGoals()- reviewSuggestion(item)- }}- />- )),- },- ]}- />- </div>- )}- <nav aria-label="Dashboard sections" className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-3">- {sections.map(({ key, title, description, icon }) => (+ ]}+ />+ </div>+ )}+ </div>+ <nav aria-label="Dashboard sections" className="flex flex-wrap gap-1 rounded border p-1 w-fit max-w-full">+ {sections.map(({ key, title, icon }) => (<LemonButtonkey={key}- type={activeSection === key ? 'primary' : 'secondary'}+ type="tertiary"+ active={activeSection === key}+ className={activeSection === key ? '!bg-accent-highlight !text-accent' : undefined}+ icon={icon}+ size="small"+ data-attr={`marketing-dashboard-section-${key}`}onClick={() => setSelectedSection(key)}aria-pressed={activeSection === key}aria-controls="marketing-dashboard-section"- className="h-full"- fullWidth>- <div className="flex flex-col gap-2 py-2 text-left">- <span className="flex items-center gap-2 text-lg font-semibold">- {icon}- {title}- </span>- <span className="font-normal">{description}</span>- </div>+ {title}</LemonButton>))}</nav>@@ -290,6 +290,9 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {.map(({ title, keys }) => (<section key={title} className="flex flex-col gap-2" aria-label={title}><h2 className="mb-0">{title}</h2>+ <p className="text-secondary mb-2">+ {sections.find(({ key }) => key === activeSection)?.description}+ </p><div className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,12rem),1fr))] auto-rows-fr gap-2"><div className="contents"><OverviewMetricCardGrid@@ -347,6 +350,9 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {{activeSection === 'conversion' && (<section aria-label="Conversion" className="flex flex-col gap-2"><h2 className="mb-0">Conversion</h2>+ <p className="text-secondary mb-2">+ {sections.find(({ key }) => key === activeSection)?.description}+ </p><AttributionTab /></section>)}@@ -418,51 +424,105 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {)}{isTraffic && (<>- <div className="flex items-center gap-2">- <span>Breakdown by</span>- <LemonSelect- value={trafficBreakdown}- onChange={setTrafficBreakdown}- options={TRAFFIC_BREAKDOWNS}- aria-label="Traffic breakdown"- />- </div>- <Query- query={{- kind: NodeKind.DataTableNode,- source: {- kind: NodeKind.WebStatsTableQuery,- breakdownBy: trafficBreakdown,- orderBy: trafficOrderBy[activeSection],- dateRange,+ {activeSection === 'acquisition' && (+ <LemonCard hoverEffect={false}>+ <h3>Visitors over time</h3>+ <p className="text-secondary text-sm">All traffic in the selected period.</p>+ <div className="flex flex-col h-80">+ <Query+ key={activeSection}+ query={{+ kind: NodeKind.InsightVizNode,+ source: {+ kind: NodeKind.TrendsQuery,+ dateRange,+ compareFilter,+ filterTestAccounts: shouldFilterTestAccounts,+ interval: 'day',+ tags: MARKETING_ANALYTICS_DEFAULT_QUERY_TAGS,+ series: [+ {+ kind: NodeKind.EventsNode,+ event: null,+ properties: [+ {+ key: 'event',+ type: PropertyFilterType.EventMetadata,+ operator: PropertyOperator.Exact,+ value: ['$pageview', '$screen'],+ },+ ],+ math: BaseMathType.UniqueUsers,+ custom_name: 'Visitors',+ },+ ],+ trendsFilter: { display: ChartDisplayType.ActionsLineGraph },+ },+ embedded: true,+ showTable: false,+ hidePersonsModal: true,+ }}+ readOnly+ />+ </div>+ </LemonCard>+ )}+ <LemonCard hoverEffect={false}>+ <div className="flex flex-wrap justify-between items-center gap-2 mb-3">+ <h3 className="mb-0">+ {`${activeSection === 'acquisition' ? 'Acquisition' : 'Engagement'} by ${TRAFFIC_BREAKDOWNS.find(({ value }) => value === trafficBreakdown)?.label.toLowerCase()}`}+ </h3>+ <div className="flex items-center gap-2">+ <span>Breakdown by</span>+ <LemonSelect+ value={trafficBreakdown}+ onChange={setTrafficBreakdown}+ options={TRAFFIC_BREAKDOWNS}+ aria-label="Traffic breakdown"+ />+ </div>+ </div>+ <p className="text-secondary text-sm">+ Grouped by session entry. UTM source and referring domain are separate breakdowns.+ Visitors can appear in more than one row.+ </p>+ <Query+ query={{+ kind: NodeKind.DataTableNode,+ source: {+ kind: NodeKind.WebStatsTableQuery,+ breakdownBy: trafficBreakdown,+ orderBy: trafficOrderBy[activeSection],+ dateRange,+ compareFilter,+ filterTestAccounts: shouldFilterTestAccounts,+ includeBounceRate: activeSection === 'engagement',+ includeTrafficMetrics: activeSection === 'acquisition',+ conversionGoal: activeSection === 'acquisition' ? customerConversionGoal : null,+ properties: [],+ limit: 25,+ tags: MARKETING_ANALYTICS_DEFAULT_QUERY_TAGS,+ },+ hiddenColumns:+ activeSection === 'engagement'+ ? ['context.columns.views']+ : [+ 'context.columns.total_conversions',+ ...(customerConversionGoal ? ['context.columns.cross_sell'] : []),+ ],+ full: true,+ embedded: false,+ showOpenEditorButton: false,+ }}+ context={{+ ...marketingTrafficQueryContext(trafficOrderBy[activeSection], (field) =>+ toggleTrafficSort(activeSection, field)+ ),compareFilter,- filterTestAccounts: shouldFilterTestAccounts,- includeBounceRate: activeSection === 'engagement',- includeTrafficMetrics: activeSection === 'acquisition',- conversionGoal: activeSection === 'acquisition' ? customerConversionGoal : null,- properties: [],- limit: 25,- tags: MARKETING_ANALYTICS_DEFAULT_QUERY_TAGS,- },- hiddenColumns:- activeSection === 'engagement'- ? ['context.columns.views']- : [- 'context.columns.total_conversions',- ...(customerConversionGoal ? ['context.columns.cross_sell'] : []),- ],- full: true,- embedded: false,- showOpenEditorButton: false,- }}- context={{- ...marketingTrafficQueryContext(trafficOrderBy[activeSection], (field) =>- toggleTrafficSort(activeSection, field)- ),- compareFilter,- }}- readOnly- />+ }}+ readOnly+ />+ </LemonCard></>)}</div>