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(web-analytics): rearrange tiles and keep them visible with a conversion goal (#105242)

Mike Warren2da4283dbee5
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index e36f355a47ec..b5c1e010548d 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -13443,13 +13443,13 @@ snapshots:
scenes-app-web-analytics--web-analytics-dashboard-narrow--light:
hash: v1.k794b7964.9d31020061155395b85003dae42b77a09a84839c2b65e7a1bb6f7e764067e190.zLKSfk0tFj7IATJU0hiNbNGx2_DE5uVPPZZLQLQXqrM
scenes-app-web-analytics--web-analytics-dashboard-tile-header-v-2-medium--dark:
- hash: v1.k794b7964.865308ee7b3cc95ae6a9d3f78ff061e02cf29610e6af98af8d9793fc027f083c.zzjFc2X6UxtQq1vmXHEkobuQiEGSMX5_Q5kpKagU7Zk
+ hash: v1.k794b7964.ba43e537c83b8046afd7ff4bb61a05c6143a8ae30cb4d0fc5aa10cd0c2bb26b4.k2L76-XagrvTM-zJz1amiVEtXr1D5pdml6v57bP6JRI
scenes-app-web-analytics--web-analytics-dashboard-tile-header-v-2-medium--light:
- hash: v1.k794b7964.ea3c672066d0af122eaacb17a34da1613a5fd9a9c4afe78872f036d5481a3d38.qlkdK0-nZPYtsFp0cyegdj0iziswRMM1iJFEOWN1V2g
+ hash: v1.k794b7964.e8e3380fad8a375ea6df3522c6375011e9a8c211fb9432432d98a8074219d7c2.Qi7lh9Pa8AmXx_cLU7NKTz83gtFkR2fdqoV3F4PW57c
scenes-app-web-analytics--web-analytics-dashboard-tile-header-v-2-wide--dark:
- hash: v1.k794b7964.ef09b67b9d8cf134fa292b1d49156804eb007f718fe890bd169d0fe1d014b2f9.VJGrECMOd1vMwf1ENv4mz3knvaC1j0r9JBSlZww0R5s
+ hash: v1.k794b7964.dcf4383ad413029603aa0769919ff748fb3b6185dd4f13ed16a5d13b61cac901.cOctP1XQJRmbRU1CN7WSa-3S7k9zddfUczaxhQTVs08
scenes-app-web-analytics--web-analytics-dashboard-tile-header-v-2-wide--light:
- hash: v1.k794b7964.6df48926e7ac9f971d7365bd1862ebf290fa7ed64076a69020e613b23a3a537a.UV8gAJzodjW2qNErfweaYYvFspAKRqSdcoizfF1Jxv0
+ hash: v1.k794b7964.d1f1e26d76b67139b635a4020df243849d60d60cb8b3fe6d132980acc146e56b.WekE32-CE3pdo-V0UR852y2Fa2RwB091zWrfQr4y8-0
scenes-app-web-analytics--web-analytics-empty-onboarding-narrow--dark:
hash: v1.k794b7964.605caa854b816f8f47b5ef23cebca23dd5f2b516af151a7df08c9337663b3964.nHXW-vmDopWvz5x29U-iyNWGv9qxfOx64AqB8sykTpo
scenes-app-web-analytics--web-analytics-empty-onboarding-narrow--light:
diff --git a/frontend/src/scenes/web-analytics/webAnalyticsLogic.test.ts b/frontend/src/scenes/web-analytics/webAnalyticsLogic.test.ts
index c5346c8c6c41..9018bcad845b 100644
--- a/frontend/src/scenes/web-analytics/webAnalyticsLogic.test.ts
+++ b/frontend/src/scenes/web-analytics/webAnalyticsLogic.test.ts
@@ -408,6 +408,41 @@ describe('webAnalyticsLogic compare filter', () => {
})
})
+describe('webAnalyticsLogic conversion goal tiles', () => {
+ let logic: ReturnType<typeof webAnalyticsLogic.build>
+
+ beforeEach(() => {
+ localStorage.clear()
+ initKeaTests()
+ jest.spyOn(api.propertyDefinitions, 'list').mockResolvedValue({ results: [] } as any)
+ jest.spyOn(api.hogFunctions, 'list').mockResolvedValue({ results: [] } as any)
+ jest.spyOn(api, 'update').mockResolvedValue({} as any)
+ ;(posthog as any).setPersonProperties = jest.fn()
+ featureFlagLogic.mount()
+ logic = webAnalyticsLogic()
+ logic.mount()
+ })
+
+ afterEach(() => {
+ logic.unmount()
+ jest.restoreAllMocks()
+ })
+
+ // The replay filter group carries the conversion goal. If the error tracking query inherits it,
+ // selecting a goal silently narrows the errors the tile shows.
+ it('keeps the error tracking tile unfiltered by the conversion goal', async () => {
+ const errorTrackingFilterGroup = (): unknown =>
+ (logic.values.tiles.find((tile) => tile.tileId === TileId.ERROR_TRACKING) as any)?.query.source.filterGroup
+ const withoutGoal = errorTrackingFilterGroup()
+
+ logic.actions.setConversionGoal({ actionId: 42 })
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(withoutGoal).toBeTruthy()
+ expect(errorTrackingFilterGroup()).toEqual(withoutGoal)
+ })
+})
+
describe('webAnalyticsLogic URL restoration', () => {
let logic: ReturnType<typeof webAnalyticsLogic.build>
diff --git a/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx b/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
index f5be5e451a4c..10734e371653 100644
--- a/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
+++ b/frontend/src/scenes/web-analytics/webAnalyticsLogic.tsx
@@ -1987,7 +1987,11 @@ export const webAnalyticsLogic: LogicWrapper<webAnalyticsLogicType> = kea<webAna
orderBy: 'users',
dateRange: dateRange,
filterTestAccounts: filterTestAccounts,
- filterGroup: replayFilters.filter_group,
+ // Not replayFilters.filter_group: it carries the conversion goal, which this tile does not apply.
+ filterGroup: {
+ type: FilterLogicalOperator.And,
+ values: [{ type: FilterLogicalOperator.And, values: webAnalyticsFilters }],
+ },
columns: ['error', 'users', 'occurrences', 'last_seen'],
limit: 4,
})
@@ -2087,12 +2091,10 @@ export const webAnalyticsLogic: LogicWrapper<webAnalyticsLogicType> = kea<webAna
const useTileHeaderV2 = featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_TILE_HEADER_V2] === 'test'
// Only read the removal experiment flag where the replay tile would actually render: the
- // analytics tab with no conversion goal. allTiles is also built for the bot-analytics tab
- // (then discarded), and the tile is hidden whenever a conversion goal is set, so reading the
- // flag outside this path would enroll users neither variant affects and dilute the metrics.
+ // analytics tab. allTiles is also built for the bot-analytics tab (then discarded), so reading
+ // the flag outside this path would enroll users neither variant affects and dilute the metrics.
const removeReplayTile =
productTab === ProductTab.ANALYTICS &&
- !conversionGoal &&
featureFlags[FEATURE_FLAGS.WEB_ANALYTICS_REMOVE_REPLAY_TILE] === 'test'
const includeHostMenuItem: LemonMenuItem | null =
@@ -2658,41 +2660,13 @@ export const webAnalyticsLogic: LogicWrapper<webAnalyticsLogicType> = kea<webAna
),
],
},
- !conversionGoal && errorTrackingQ
- ? {
- kind: 'error_tracking',
- tileId: TileId.ERROR_TRACKING,
- layout: {
- colSpanClassName: 'md:col-span-2 2xl:col-span-1',
- },
- query: errorTrackingQ,
- docs: {
- url: 'https://posthog.com/docs/error-tracking',
- title: 'Error Tracking',
- description: (
- <>
- <div>
- <p>
- Error tracking allows you to track, investigate, and resolve
- exceptions your customers face.
- </p>
- <p>
- Errors are captured as <code>$exception</code> events which means that
- you can create insights, filter recordings and trigger surveys based
- on them exactly the same way you can for any other type of event.
- </p>
- </div>
- </>
- ),
- },
- }
- : null,
-
{
kind: 'tabs',
tileId: TileId.GEOGRAPHY,
layout: {
- colSpanClassName: 'md:col-span-full',
+ // Only the v2 grid packs densely, so the one-column slot next to sources and
+ // devices exists only there.
+ colSpanClassName: useTileHeaderV2 ? 'md:col-span-2 2xl:col-span-1' : 'md:col-span-full',
},
activeTabId:
geographyTab || (shouldShowGeoIPQueries ? GeographyTab.MAP : GeographyTab.LANGUAGES),
@@ -2820,58 +2794,28 @@ export const webAnalyticsLogic: LogicWrapper<webAnalyticsLogicType> = kea<webAna
] as (TabsTileTab | null)[]
).filter(isNotNil),
},
- !conversionGoal
+ errorTrackingQ
? {
- kind: 'query',
- tileId: TileId.RETENTION,
- title: 'Retention',
+ kind: 'error_tracking',
+ tileId: TileId.ERROR_TRACKING,
layout: {
colSpanClassName: 'md:col-span-full',
},
- query: {
- kind: NodeKind.InsightVizNode,
- source: {
- kind: NodeKind.RetentionQuery,
- properties: webAnalyticsFilters,
- dateRange,
- filterTestAccounts,
- retentionFilter: {
- retentionType: RETENTION_FIRST_OCCURRENCE_MATCHING_FILTERS,
- retentionReference: 'total',
- totalIntervals: isGreaterThanMd ? 8 : 5,
- period: RetentionPeriod.Week,
- },
- tags: WEB_ANALYTICS_DEFAULT_QUERY_TAGS,
- },
- vizSpecificOptions: {
- [InsightType.RETENTION]: {
- hideLineGraph: true,
- hideSizeColumn: !isGreaterThanMd,
- useSmallLayout: !isGreaterThanMd,
- },
- },
- embedded: true,
- },
- insightProps: createInsightProps(TileId.RETENTION),
- canOpenInsight: true,
- canOpenModal: true,
+ query: errorTrackingQ,
docs: {
- url: 'https://posthog.com/docs/web-analytics/dashboard#retention',
- title: 'Retention',
+ url: 'https://posthog.com/docs/error-tracking',
+ title: 'Error Tracking',
description: (
<>
<div>
<p>
- Retention creates a cohort of unique users who performed any event for
- the first time in the last week. It then tracks the percentage of
- users who return to perform any event in the following weeks.
+ Error tracking allows you to track, investigate, and resolve
+ exceptions your customers face.
</p>
<p>
- You want the numbers to be the highest possible, suggesting that
- people that come to your page continue coming to your page - and
- performing an actions. Also, the further down the table the higher the
- numbers should be (or at least as high), which would indicate that
- you're either increasing or keeping your retention at the same level.
+ Errors are captured as <code>$exception</code> events which means that
+ you can create insights, filter recordings and trigger surveys based
+ on them exactly the same way you can for any other type of event.
</p>
</div>
</>
@@ -2879,6 +2823,63 @@ export const webAnalyticsLogic: LogicWrapper<webAnalyticsLogicType> = kea<webAna
},
}
: null,
+ {
+ kind: 'query',
+ tileId: TileId.RETENTION,
+ title: 'Retention',
+ layout: {
+ colSpanClassName: 'md:col-span-full',
+ },
+ query: {
+ kind: NodeKind.InsightVizNode,
+ source: {
+ kind: NodeKind.RetentionQuery,
+ properties: webAnalyticsFilters,
+ dateRange,
+ filterTestAccounts,
+ retentionFilter: {
+ retentionType: RETENTION_FIRST_OCCURRENCE_MATCHING_FILTERS,
+ retentionReference: 'total',
+ totalIntervals: isGreaterThanMd ? 8 : 5,
+ period: RetentionPeriod.Week,
+ },
+ tags: WEB_ANALYTICS_DEFAULT_QUERY_TAGS,
+ },
+ vizSpecificOptions: {
+ [InsightType.RETENTION]: {
+ hideLineGraph: true,
+ hideSizeColumn: !isGreaterThanMd,
+ useSmallLayout: !isGreaterThanMd,
+ },
+ },
+ embedded: true,
+ },
+ insightProps: createInsightProps(TileId.RETENTION),
+ canOpenInsight: true,
+ canOpenModal: true,
+ docs: {
+ url: 'https://posthog.com/docs/web-analytics/dashboard#retention',
+ title: 'Retention',
+ description: (
+ <>
+ <div>
+ <p>
+ Retention creates a cohort of unique users who performed any event for the
+ first time in the last week. It then tracks the percentage of users who
+ return to perform any event in the following weeks.
+ </p>
+ <p>
+ You want the numbers to be the highest possible, suggesting that people that
+ come to your page continue coming to your page - and performing an actions.
+ Also, the further down the table the higher the numbers should be (or at
+ least as high), which would indicate that you're either increasing or
+ keeping your retention at the same level.
+ </p>
+ </div>
+ </>
+ ),
+ },
+ },
{
kind: 'tabs',
tileId: TileId.ACTIVE_HOURS,
@@ -3022,80 +3023,81 @@ export const webAnalyticsLogic: LogicWrapper<webAnalyticsLogicType> = kea<webAna
},
],
},
- // Hiding if conversionGoal is set already because values aren't representative
- !conversionGoal
- ? {
- kind: 'query',
- tileId: TileId.GOALS,
- title: 'Goals',
- layout: {
- colSpanClassName: 'md:col-span-full',
- },
- query: {
- full: true,
- kind: NodeKind.DataTableNode,
- source: {
- kind: NodeKind.WebGoalsQuery,
- properties: webAnalyticsFilters,
- dateRange,
- compareFilter,
- limit: 10,
- orderBy: tablesOrderBy ?? undefined,
- filterTestAccounts,
- tags: WEB_ANALYTICS_DEFAULT_QUERY_TAGS,
- // Backend gate decides whether this query is actually served
- // from the precomputed table; we just pass the per-team opt-in.
- useWebAnalyticsPrecompute,
+ {
+ kind: 'query',
+ tileId: TileId.GOALS,
+ title: 'Goals',
+ layout: {
+ colSpanClassName:
+ removeReplayTile || hiddenTiles.includes(TileId.REPLAY)
+ ? 'md:col-span-full'
+ : 'md:col-span-2 2xl:col-span-2',
+ },
+ query: {
+ full: true,
+ kind: NodeKind.DataTableNode,
+ source: {
+ kind: NodeKind.WebGoalsQuery,
+ properties: webAnalyticsFilters,
+ dateRange,
+ compareFilter,
+ limit: 10,
+ orderBy: tablesOrderBy ?? undefined,
+ filterTestAccounts,
+ tags: WEB_ANALYTICS_DEFAULT_QUERY_TAGS,
+ // Backend gate decides whether this query is actually served
+ // from the precomputed table; we just pass the per-team opt-in.
+ useWebAnalyticsPrecompute,
+ },
+ embedded: true,
+ showActions: true,
+ columns: ['breakdown_value', 'visitors', 'views', 'cross_sell'],
+ },
+ insightProps: createInsightProps(TileId.GOALS),
+ canOpenInsight: false,
+ extraMenuItems: useTileHeaderV2
+ ? [
+ {
+ label: 'Manage actions',
+ icon: <IconOpenInNew />,
+ to: urls.actions(),
+ onClick: () => {
+ void addProductIntentForCrossSell({
+ from: ProductKey.WEB_ANALYTICS,
+ to: ProductKey.ACTIONS,
+ intent_context: ProductIntentContext.WEB_ANALYTICS_INSIGHT,
+ })
+ },
},
- embedded: true,
- showActions: true,
- columns: ['breakdown_value', 'visitors', 'views', 'cross_sell'],
- },
- insightProps: createInsightProps(TileId.GOALS),
- canOpenInsight: false,
- extraMenuItems: useTileHeaderV2
- ? [
- {
- label: 'Manage actions',
- icon: <IconOpenInNew />,
- to: urls.actions(),
- onClick: () => {
- void addProductIntentForCrossSell({
- from: ProductKey.WEB_ANALYTICS,
- to: ProductKey.ACTIONS,
- intent_context: ProductIntentContext.WEB_ANALYTICS_INSIGHT,
- })
- },
- },
- ]
- : undefined,
- docs: {
- url: 'https://posthog.com/docs/web-analytics/dashboard#goals',
- title: 'Goals',
- description: (
- <>
- <div>
- <p>
- Goals shows your pinned or most recently created actions and the
- number of conversions they've had. You can set a custom event or
- action as a{' '}
- <Link to="https://posthog.com/docs/web-analytics/conversion-goals">
- conversion goal
- </Link>{' '}
- at the top of the dashboard for more specific metrics.
- </p>
- </div>
- </>
- ),
- },
- }
- : null,
- !conversionGoal && !removeReplayTile
+ ]
+ : undefined,
+ docs: {
+ url: 'https://posthog.com/docs/web-analytics/dashboard#goals',
+ title: 'Goals',
+ description: (
+ <>
+ <div>
+ <p>
+ Goals shows your pinned or most recently created actions and the number of
+ conversions they've had. You can set a custom event or action as a{' '}
+ <Link to="https://posthog.com/docs/web-analytics/conversion-goals">
+ conversion goal
+ </Link>{' '}
+ at the top of the dashboard for more specific metrics.
+ </p>
+ </div>
+ </>
+ ),
+ },
+ },
+ !removeReplayTile
? {
kind: 'replay',
tileId: TileId.REPLAY,
layout: {
- colSpanClassName: conversionGoal ? 'md:col-span-full' : 'md:col-span-1',
+ colSpanClassName: hiddenTiles.includes(TileId.GOALS)
+ ? 'md:col-span-full'
+ : 'md:col-span-2 2xl:col-span-1',
},
docs: {
url: 'https://posthog.com/docs/session-replay',
@@ -3105,75 +3107,72 @@ export const webAnalyticsLogic: LogicWrapper<webAnalyticsLogicType> = kea<webAna
},
}
: null,
- !conversionGoal
- ? {
- kind: 'query',
- title: 'Frustrating Pages',
- tileId: TileId.FRUSTRATING_PAGES,
- layout: {
- colSpanClassName: 'md:col-span-full',
- },
- query: {
- full: true,
- kind: NodeKind.DataTableNode,
- source: {
- kind: NodeKind.WebStatsTableQuery,
- breakdownBy: WebStatsBreakdown.FrustrationMetrics,
- dateRange,
- filterTestAccounts,
- properties: webAnalyticsFilters,
- compareFilter,
- limit: 10,
- doPathCleaning: isPathCleaningEnabled,
- tags: WEB_ANALYTICS_DEFAULT_QUERY_TAGS,
- // The backend frustration lazy precompute gate decides whether
- // this query is actually served from the precomputed table; we
- // just pass the per-team opt-in through so it's eligible.
- useWebAnalyticsPrecompute,
- },
- embedded: true,
- showActions: true,
- hiddenColumns: ['views'],
- },
- insightProps: createInsightProps(TileId.FRUSTRATING_PAGES, 'table'),
- canOpenModal: true,
- canOpenInsight: true,
- docs: {
- title: 'Frustrating Pages',
- description: (
- <>
- <div>
- <p>
- See which pages are causing frustration by monitoring rage clicks,
- dead clicks, and errors.
- </p>
- <p>
- <ul>
- <li>
- A dead click is a click that doesn't result in any action.
- E.g. an image that looks like a button.
- </li>
- <li>
- Rageclicks are collected when a user clicks on a static
- element more than three times in a one-second window.
- </li>
- <li>
- Errors are JavaScript exceptions that occur when users
- interact with your site.
- </li>
- </ul>
- </p>
- <p>
- These are captured automatically and can help identify broken
- functionality, failed API calls, or other technical issues that
- frustrate users.
- </p>
- </div>
- </>
- ),
- },
- }
- : null,
+ {
+ kind: 'query',
+ title: 'Frustrating Pages',
+ tileId: TileId.FRUSTRATING_PAGES,
+ layout: {
+ colSpanClassName: 'md:col-span-full',
+ },
+ query: {
+ full: true,
+ kind: NodeKind.DataTableNode,
+ source: {
+ kind: NodeKind.WebStatsTableQuery,
+ breakdownBy: WebStatsBreakdown.FrustrationMetrics,
+ dateRange,
+ filterTestAccounts,
+ properties: webAnalyticsFilters,
+ compareFilter,
+ limit: 10,
+ doPathCleaning: isPathCleaningEnabled,
+ tags: WEB_ANALYTICS_DEFAULT_QUERY_TAGS,
+ // The backend frustration lazy precompute gate decides whether
+ // this query is actually served from the precomputed table; we
+ // just pass the per-team opt-in through so it's eligible.
+ useWebAnalyticsPrecompute,
+ },
+ embedded: true,
+ showActions: true,
+ hiddenColumns: ['views'],
+ },
+ insightProps: createInsightProps(TileId.FRUSTRATING_PAGES, 'table'),
+ canOpenModal: true,
+ canOpenInsight: true,
+ docs: {
+ title: 'Frustrating Pages',
+ description: (
+ <>
+ <div>
+ <p>
+ See which pages are causing frustration by monitoring rage clicks, dead
+ clicks, and errors.
+ </p>
+ <p>
+ <ul>
+ <li>
+ A dead click is a click that doesn't result in any action. E.g. an
+ image that looks like a button.
+ </li>
+ <li>
+ Rageclicks are collected when a user clicks on a static element more
+ than three times in a one-second window.
+ </li>
+ <li>
+ Errors are JavaScript exceptions that occur when users interact with
+ your site.
+ </li>
+ </ul>
+ </p>
+ <p>
+ These are captured automatically and can help identify broken functionality,
+ failed API calls, or other technical issues that frustrate users.
+ </p>
+ </div>
+ </>
+ ),
+ },
+ },
]
// Bot analytics tiles live in `botAnalyticsLogic` so the bot tab keeps its own