: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): surface conversion goal suggestions on the dashboard (#100245)
Javier Bahamondes1948c5023647
diff --git a/docs/internal/marketing-analytics-configuration-writes.md b/docs/internal/marketing-analytics-configuration-writes.mdindex d8a1155cc958..86e422fbdce6 100644--- a/docs/internal/marketing-analytics-configuration-writes.md+++ b/docs/internal/marketing-analytics-configuration-writes.md@@ -38,6 +38,10 @@ The bypass waits for feature flags before mounting setup detection. The explicitWith `new-marketing-analytics-dashboard` enabled, Ad performance reuses the existing ad spend dashboard. Its conversion-goal switch appears only when goals are configured and defaults to on. Turning it off limits the summary and table queries to ad-platform metrics, including platform-reported conversions, and omits saved and draft PostHog conversion goals. This preference applies only to Ad performance; leaving the tab or disabling the dashboard flag restores the legacy queries and saved column choices. Ad performance keeps source status and reconnect controls visible when loading sources fails, without entering legacy onboarding.+The new dashboard shows the conversion-goal suggestions from Setup, including missing New user and Revenue classifications. Review in Setup opens the existing configuration flow. Dismissed suggestions remain recoverable in Setup, and collapsing the dashboard suggestions persists in local storage. This does not create goals automatically or change candidate ranking.++When the main content panel is narrow, Setup provides a section selector in place of the sidebar. Dashboard suggestion headers keep Review in Setup beside the title.+The new dashboard opens on Acquisition. Its section tiles show one section at a time while preserving the shared date and comparison filters. Retention, Conversion, and Revenue tiles follow their existing feature flags.Acquisition and Engagement reuse the Web Analytics stats table with a shared traffic breakdown selector. The Acquisition table shows visitors and pageviews; the Engagement table shows visitors and bounce rate. Summary cards remain visitors, sessions, and pageviews for Acquisition, and session duration and bounce rate for Engagement. Changing sections preserves the selected breakdown, date range, and comparison.diff --git a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.goals.test.tsx b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.goals.test.tsxnew file mode 100644index 000000000000..57031ab9b35d--- /dev/null+++ b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.goals.test.tsx@@ -0,0 +1,86 @@+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'++import {+ marketingAnalyticsLogic,+ MarketingAnalyticsTab,+ SetupSection,+} from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic'+import { setupPlanLogic } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import { NewMarketingAnalyticsDashboard } from './NewMarketingAnalyticsDashboard'++jest.mock('scenes/web-analytics/tiles/WebAnalyticsTile', () => ({ webAnalyticsDataTableQueryContext: {} }))+jest.mock('~/queries/Query/Query', () => ({ Query: () => null }))+jest.mock('scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionTable', () => ({+ AttributionTable: () => null,+}))+jest.mock('scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionTab', () => ({+ AttributionTab: () => null,+}))++describe('Dashboard goal suggestions', () => {+ it('reuses goal suggestions, remembers collapse and opens their review in Setup', async () => {+ useMocks({+ get: {+ '/api/projects/:team_id/marketing_analytics/setup_plan': () => [+ 200,+ {+ suggestions: [+ {+ id: 'mark_goal_as_revenue:purchase',+ kind: 'mark_goal_as_revenue',+ also_recommended: [],+ title: 'Mark a revenue goal',+ evidence: 'Choose which goal measures revenue.',+ source: 'deterministic',+ severity: 'info',+ unlocks: [],+ apply: {+ op: 'update_conversion_goal',+ conversion_goal_id: 'purchase',+ patch: { counts_as_revenue: true },+ },+ },+ ],+ readiness: [],+ degraded: [],+ truncated: false,+ summary: '',+ },+ ],+ },+ })+ initKeaTests()+ localStorage.removeItem('marketing-goal-suggestions-expanded')+ const unmountMarketing = marketingAnalyticsLogic.mount()+ const unmountSetup = setupPlanLogic.mount()+ const view = render(<NewMarketingAnalyticsDashboard />)+ try {+ await screen.findByText('Mark a revenue goal')+ fireEvent.click(screen.getByText('Suggested conversion goals (1)'))+ expect(localStorage.getItem('marketing-goal-suggestions-expanded')).toBe('false')+ view.unmount()+ render(<NewMarketingAnalyticsDashboard />)+ expect(+ screen+ .getByText('Suggested conversion goals (1)')+ .closest('[aria-expanded]')+ ?.getAttribute('aria-expanded')+ ).toBe('false')+ fireEvent.click(screen.getByText('Suggested conversion goals (1)'))+ fireEvent.click(screen.getByText('Review change', { exact: true }))+ await waitFor(() => expect(marketingAnalyticsLogic.values.activeTab).toBe(MarketingAnalyticsTab.SETUP))+ expect(marketingAnalyticsLogic.values.setupSection).toBe(SetupSection.CONVERSION_GOALS)+ expect(setupPlanLogic.values.reviewingSuggestion?.id).toBe('mark_goal_as_revenue:purchase')+ fireEvent.click(screen.getByText('Dismiss'))+ await waitFor(() => expect(screen.queryByText('Suggested conversion goals (1)')).toBeNull())+ } finally {+ cleanup()+ unmountSetup()+ unmountMarketing()+ }+ })+})diff --git a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsx b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsxindex 1a554f2343e6..a2949be49a7d 100644--- a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsx+++ b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.test.tsx@@ -5,6 +5,8 @@ import { FEATURE_FLAGS } from 'lib/constants'import { NewMarketingAnalyticsDashboard } from './NewMarketingAnalyticsDashboard'+jest.mock('./Setup/sectionRouting', () => ({ suggestionsForSection: () => [] }))+jest.mock('./Setup/SuggestionRow', () => ({ SuggestionRow: () => null }))jest.mock('kea', () => ({ ...jest.requireActual('kea'), useValues: jest.fn(), useActions: () => ({}) }))@@ -48,6 +50,7 @@ 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: {},+ SetupSection: { CONVERSION_GOALS: 'conversion-goals' },}))jest.mock('scenes/web-analytics/tabs/marketing-analytics/frontend/shared', () => ({MarketingAnalyticsCell: () => null,diff --git a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsxindex 53424576008d..f56764a9e5b6 100644--- a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx+++ b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx@@ -37,6 +37,7 @@ import {} from '~/queries/schema/schema-general'import { QueryContext } from '~/queries/types'+import { suggestionsForSection } from './Setup/sectionRouting'import { SuggestionRow } from './Setup/SuggestionRow'const TRAFFIC_BREAKDOWNS = [@@ -120,6 +121,13 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {setActiveTab(MarketingAnalyticsTab.SETUP)}+ const [goalsExpanded, setGoalsExpanded] = useLocalStorage('marketing-goal-suggestions-expanded', true)+ const goalSuggestions = suggestionsForSection(visibleSuggestions, SetupSection.CONVERSION_GOALS)+ const reviewGoals = (): void => {+ setSetupSection(SetupSection.CONVERSION_GOALS)+ setActiveTab(MarketingAnalyticsTab.SETUP)+ }+const requestedSetupPlan = useRef(false)useEffect(() => {if (!setupPlan && !setupPlanLoading && !requestedSetupPlan.current) {@@ -156,12 +164,10 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {)}</div>{sourceSuggestions.length > 0 && (- <div className="border rounded">- <div className="flex justify-end p-2">- <LemonButton size="small" onClick={reviewSources}>- Review in Setup- </LemonButton>- </div>+ <div className="border rounded relative">+ <LemonButton className="absolute right-2 top-0 z-10" size="small" onClick={reviewSources}>+ Review in Setup+ </LemonButton><LemonCollapseembeddedsize="small"@@ -170,7 +176,10 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {panels={[{key: 'sources',- header: `Suggested ad sources (${sourceSuggestions.length})`,+ header: {+ children: `Suggested ad sources (${sourceSuggestions.length})`,+ className: 'pr-36',+ },content: sourceSuggestions.map((suggestion) => (<SuggestionRowkey={suggestion.id}@@ -187,6 +196,39 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {/></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)+ }}+ />+ )),+ },+ ]}+ />+ </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 }) => (<LemonButtondiff --git a/frontend/src/scenes/marketing-analytics/Setup/SetupTab.tsx b/frontend/src/scenes/marketing-analytics/Setup/SetupTab.tsxindex a0acff358cf1..9adbd2211e17 100644--- a/frontend/src/scenes/marketing-analytics/Setup/SetupTab.tsx+++ b/frontend/src/scenes/marketing-analytics/Setup/SetupTab.tsx@@ -2,7 +2,7 @@ import { useActions, useValues } from 'kea'import posthog from 'posthog-js'import { useEffect } from 'react'-import { LemonButton, LemonTag } from '@posthog/lemon-ui'+import { LemonButton, LemonSelect, LemonTag } from '@posthog/lemon-ui'import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'@@ -76,8 +76,17 @@ export function SetupTab(): JSX.Element {}, [active.key])return (- <div className="flex flex-col md:flex-row gap-6 mt-4">- <nav className="md:w-56 shrink-0 flex flex-row md:flex-col gap-px overflow-x-auto">+ <div className="flex flex-col @min-[48rem]/main-content:flex-row gap-6 mt-4">+ <div className="@min-[48rem]/main-content:hidden">+ <LemonSelect+ fullWidth+ value={active.key}+ onChange={setSetupSection}+ options={sections.map((section) => ({ value: section.key, label: section.label }))}+ aria-label="Setup section"+ />+ </div>+ <nav className="hidden @min-[48rem]/main-content:flex w-56 shrink-0 flex-col gap-px">{sections.map((section) => (<LemonButtonkey={section.key}