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 source suggestions in the new dashboard (#99595)

Javier Bahamondes2e50a3214823
diff --git a/docs/internal/marketing-analytics-configuration-writes.md b/docs/internal/marketing-analytics-configuration-writes.md
index fea395b6787c..8cc3bdbf92c7 100644
--- a/docs/internal/marketing-analytics-configuration-writes.md
+++ b/docs/internal/marketing-analytics-configuration-writes.md
@@ -26,6 +26,10 @@ Engagement displays session duration and bounce rate from the same Web Overview
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 shows undismissed ad-source connection suggestions from the existing Setup plan. The accordion remembers its expanded state in local storage. Connect opens the existing review in Setup; sources are never connected automatically. Dismissed suggestions can be restored in Setup.
+
+Each Setup section also lists its dismissed suggestions behind Show dismissed, with an individual Restore action. This remains available when all suggestions in that section are dismissed.
+
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.
With `new-marketing-analytics-dashboard` enabled, Marketing Analytics opens directly without the product welcome screen or its setup reminder. Existing setup status and local skip preferences remain unchanged; disabling the flag restores the previous onboarding behavior. Configuration remains available in Setup.
diff --git a/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx b/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx
index 4f747c2e2107..fec5a599aa97 100644
--- a/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx
+++ b/frontend/src/scenes/marketing-analytics/MarketingAnalyticsScene.tsx
@@ -41,6 +41,7 @@ import {
MARKETING_ANALYTICS_DATA_COLLECTION_NODE_ID,
marketingAnalyticsTilesLogic,
} from '../web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsTilesLogic'
+import { setupPlanLogic } from '../web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic'
import { NewMarketingAnalyticsDashboard } from './NewMarketingAnalyticsDashboard'
import { marketingOnboardingLogic } from './Onboarding/marketingOnboardingLogic'
import { Onboarding } from './Onboarding/Onboarding'
@@ -447,6 +448,13 @@ const MarketingAnalyticsAIToolWrapper = ({ children }: { children: React.ReactNo
}
export function MarketingAnalyticsScene(): JSX.Element {
+ const { featureFlags } = useValues(featureFlagLogic)
+ const newDashboardEnabled = !!featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_NEW_DASHBOARD]
+ useEffect(() => {
+ if (newDashboardEnabled) {
+ return setupPlanLogic.mount()
+ }
+ }, [newDashboardEnabled])
const { activeTab } = useValues(marketingAnalyticsLogic)
return (
diff --git a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.sources.test.tsx b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.sources.test.tsx
new file mode 100644
index 000000000000..8b5811d557b1
--- /dev/null
+++ b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.sources.test.tsx
@@ -0,0 +1,77 @@
+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('~/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,
+}))
+
+it('reuses source suggestions, remembers collapse and opens their review in Setup', async () => {
+ useMocks({
+ get: {
+ '/api/projects/:team_id/marketing_analytics/setup_plan': () => [
+ 200,
+ {
+ suggestions: [
+ {
+ id: 'connect_source:GoogleAds',
+ kind: 'connect_source',
+ also_recommended: [],
+ title: 'Connect Google Ads',
+ evidence: 'Traffic contains Google Ads tags.',
+ integration: 'GoogleAds',
+ source: 'deterministic',
+ severity: 'info',
+ unlocks: [],
+ apply: { op: 'open_source_wizard', kind: 'GoogleAds' },
+ },
+ ],
+ readiness: [],
+ degraded: [],
+ truncated: false,
+ summary: '',
+ },
+ ],
+ },
+ })
+ initKeaTests()
+ localStorage.removeItem('marketing-source-suggestions-expanded')
+ const unmountMarketing = marketingAnalyticsLogic.mount()
+ const unmountSetup = setupPlanLogic.mount()
+ const view = render(<NewMarketingAnalyticsDashboard />)
+ try {
+ await screen.findByText('Connect Google Ads')
+ fireEvent.click(screen.getByText('Suggested ad sources (1)'))
+ expect(localStorage.getItem('marketing-source-suggestions-expanded')).toBe('false')
+ view.unmount()
+ render(<NewMarketingAnalyticsDashboard />)
+ expect(
+ screen.getByText('Suggested ad sources (1)').closest('[aria-expanded]')?.getAttribute('aria-expanded')
+ ).toBe('false')
+ fireEvent.click(screen.getByText('Suggested ad sources (1)'))
+ fireEvent.click(screen.getByText('Connect', { exact: true }))
+ await waitFor(() => expect(marketingAnalyticsLogic.values.activeTab).toBe(MarketingAnalyticsTab.SETUP))
+ expect(marketingAnalyticsLogic.values.setupSection).toBe(SetupSection.SOURCES)
+ expect(setupPlanLogic.values.reviewingSuggestion?.id).toBe('connect_source:GoogleAds')
+ fireEvent.click(screen.getByText('Dismiss'))
+ await waitFor(() => expect(screen.queryByText('Suggested ad sources (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.tsx
index 52fec458df64..66c39f740177 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/SuggestionRow', () => ({ SuggestionRow: () => null }))
+
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 }))
@@ -25,6 +27,8 @@ 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/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic', () => ({ setupPlanLogic: {} }))
+
jest.mock('scenes/teamLogic', () => ({ teamLogic: {} }))
jest.mock('scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAttributionLogic', () => ({
marketingAttributionLogic: {},
@@ -54,6 +58,8 @@ describe('NewMarketingAnalyticsDashboard', () => {
compareFilter: { compare: false },
shouldFilterTestAccounts: false,
responseLoading: false,
+ setupPlan: {},
+ visibleSuggestions: [],
})
render(<NewMarketingAnalyticsDashboard />)
diff --git a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx
index 61f717844cfa..0ff7d4319bf0 100644
--- a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx
+++ b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx
@@ -1,10 +1,12 @@
import { useActions, useValues } from 'kea'
+import { useEffect, useRef } from 'react'
-import { LemonBanner, LemonButton, LemonSelect, LemonSkeleton } from '@posthog/lemon-ui'
+import { LemonBanner, LemonButton, LemonCollapse, LemonSelect, LemonSkeleton } from '@posthog/lemon-ui'
import { CompareFilter } from 'lib/components/CompareFilter/CompareFilter'
import { DateFilter } from 'lib/components/DateFilter/DateFilter'
import { FEATURE_FLAGS } from 'lib/constants'
+import { useLocalStorage } from 'lib/hooks/useLocalStorage'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { teamLogic } from 'scenes/teamLogic'
import { MARKETING_ANALYTICS_DEFAULT_QUERY_TAGS } from 'scenes/web-analytics/common'
@@ -18,6 +20,7 @@ import {
} from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic'
import { marketingAttributionLogic } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAttributionLogic'
import { BREAKDOWN_LABELS } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingBreakdown'
+import { setupPlanLogic } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic'
import { MarketingAnalyticsCell } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/shared'
import { webAnalyticsDataTableQueryContext } from 'scenes/web-analytics/tiles/WebAnalyticsTile'
@@ -36,6 +39,8 @@ import {
} from '~/queries/schema/schema-general'
import { QueryContext, QueryContextColumn } from '~/queries/types'
+import { SuggestionRow } from './Setup/SuggestionRow'
+
// Channel is the top level because it covers all traffic, not just the platforms with a
// connected ad source. Source is the second column so a channel breaks down into the
// sources that make it up.
@@ -98,6 +103,23 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {
const { setRevenueGoalId, setBreakdownBy } = useActions(marketingAttributionLogic)
const { dateFilter, compareFilter, shouldFilterTestAccounts } = useValues(marketingAnalyticsLogic)
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 sourceSuggestions = visibleSuggestions.filter((suggestion) => suggestion.kind === 'connect_source')
+ const reviewSources = (): void => {
+ setSetupSection(SetupSection.SOURCES)
+ setActiveTab(MarketingAnalyticsTab.SETUP)
+ }
+
+ const requestedSetupPlan = useRef(false)
+ useEffect(() => {
+ if (!setupPlan && !setupPlanLoading && !requestedSetupPlan.current) {
+ requestedSetupPlan.current = true
+ loadSetupPlan()
+ }
+ }, [setupPlan, setupPlanLoading, loadSetupPlan])
+
const dateRange = { date_from: dateFilter.dateFrom, date_to: dateFilter.dateTo }
const query: WebOverviewQuery = {
kind: NodeKind.WebOverviewQuery,
@@ -121,6 +143,38 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {
Reload summary
</LemonButton>
</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>
+ <LemonCollapse
+ embedded
+ size="small"
+ activeKey={sourcesExpanded ? 'sources' : null}
+ onChange={(key) => setSourcesExpanded(key !== null)}
+ panels={[
+ {
+ key: 'sources',
+ header: `Suggested ad sources (${sourceSuggestions.length})`,
+ content: sourceSuggestions.map((suggestion) => (
+ <SuggestionRow
+ key={suggestion.id}
+ suggestion={suggestion}
+ currentSection={SetupSection.SOURCES}
+ onReview={(item) => {
+ reviewSources()
+ reviewSuggestion(item)
+ }}
+ />
+ )),
+ },
+ ]}
+ />
+ </div>
+ )}
{responseError ? (
<LemonBanner type="error" action={{ children: 'Retry', onClick: () => loadData('force_async') }}>
Could not load traffic metrics. Try again.
diff --git a/frontend/src/scenes/marketing-analytics/Setup/SectionSuggestions.tsx b/frontend/src/scenes/marketing-analytics/Setup/SectionSuggestions.tsx
index 80d37f13752b..ca2783d48593 100644
--- a/frontend/src/scenes/marketing-analytics/Setup/SectionSuggestions.tsx
+++ b/frontend/src/scenes/marketing-analytics/Setup/SectionSuggestions.tsx
@@ -1,4 +1,7 @@
import { useActions, useValues } from 'kea'
+import { useState } from 'react'
+
+import { LemonButton } from '@posthog/lemon-ui'
import { SetupSection } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic'
import { setupPlanLogic } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic'
@@ -9,11 +12,14 @@ import { SuggestionRow } from './SuggestionRow'
/** One section's suggestions, above its manual controls. The same rows as "Suggested
* setup" rather than a summary, so there's no second rendering to keep in sync. */
export function SectionSuggestions({ section }: { section: SetupSection }): JSX.Element | null {
- const { visibleSuggestions } = useValues(setupPlanLogic)
+ const { visibleSuggestions, dismissedSuggestions } = useValues(setupPlanLogic)
const { reviewSuggestion } = useActions(setupPlanLogic)
+ const [dismissedSection, setDismissedSection] = useState<SetupSection | null>(null)
+ const showDismissed = dismissedSection === section
const forSection = suggestionsForSection(visibleSuggestions, section)
- if (!forSection.length) {
+ const dismissedForSection = suggestionsForSection(dismissedSuggestions, section)
+ if (!forSection.length && !dismissedForSection.length) {
return null
}
@@ -27,6 +33,27 @@ export function SectionSuggestions({ section }: { section: SetupSection }): JSX.
currentSection={section}
/>
))}
+ {dismissedForSection.length > 0 && (
+ <>
+ <LemonButton
+ size="small"
+ onClick={() => setDismissedSection(showDismissed ? null : section)}
+ className="m-2"
+ >
+ {showDismissed ? 'Hide dismissed' : 'Show dismissed'} ({dismissedForSection.length})
+ </LemonButton>
+ {showDismissed &&
+ dismissedForSection.map((suggestion) => (
+ <SuggestionRow
+ key={suggestion.id}
+ suggestion={suggestion}
+ onReview={reviewSuggestion}
+ currentSection={section}
+ isDismissed
+ />
+ ))}
+ </>
+ )}
</div>
)
}