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 attributed revenue in the new dashboard (#99251)

Javier Bahamondes324156da4fe9
diff --git a/docs/internal/marketing-analytics-configuration-writes.md b/docs/internal/marketing-analytics-configuration-writes.md
index 958f666adad1..d3ef1525cc20 100644
--- a/docs/internal/marketing-analytics-configuration-writes.md
+++ b/docs/internal/marketing-analytics-configuration-writes.md
@@ -18,6 +18,10 @@ Payloads exclude suggestion IDs, titles, evidence, goal names and UTM values. So
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.
+Revenue in the new dashboard uses event/action goals marked as revenue that sum an amount property. It displays one goal at a time through the existing attribution table, counts repeat purchases and shares attribution date, breakdown and exclusion filters. Projects without eligible goals link to Setup. Warehouse goals remain in Ad performance.
+
+Revenue ranks rows by their highest attributed value across models before the server limit and chart limit. Conversion queries retain conversion-count ordering.
+
Engagement displays session duration and bounce rate from the same Web Overview response as Acquisition. Both sections share date, comparison and test-account filters; rendering Engagement adds no extra query.
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.
diff --git a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx
index 49f3687813d5..22c1f4b2671d 100644
--- a/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx
+++ b/frontend/src/scenes/marketing-analytics/NewMarketingAnalyticsDashboard.tsx
@@ -1,14 +1,22 @@
import { useActions, useValues } from 'kea'
-import { LemonBanner, LemonButton } from '@posthog/lemon-ui'
+import { LemonBanner, LemonButton, 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 { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { teamLogic } from 'scenes/teamLogic'
import { MARKETING_ANALYTICS_DEFAULT_QUERY_TAGS } from 'scenes/web-analytics/common'
import { AttributionTab } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionTab'
-import { marketingAnalyticsLogic } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic'
+import { AttributionTable } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionTable'
+import {
+ MarketingAnalyticsTab,
+ SetupSection,
+ marketingAnalyticsLogic,
+} 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 { MarketingAnalyticsCell } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/shared'
import { webAnalyticsDataTableQueryContext } from 'scenes/web-analytics/tiles/WebAnalyticsTile'
@@ -18,6 +26,7 @@ import { labelFromKey } from '~/queries/nodes/WebOverview/WebOverview'
import { Query } from '~/queries/Query/Query'
import {
DataTableNode,
+ MarketingAnalyticsAttributionBreakdown,
MarketingAnalyticsBaseColumns,
MarketingAnalyticsDrillDownLevel,
NodeKind,
@@ -82,9 +91,12 @@ 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 { currentTeam, currentTeamLoading } = useValues(teamLogic)
const { featureFlags } = useValues(featureFlagLogic)
+ const { revenueGoals, selectedRevenueGoalId, revenueQuery, breakdownBy } = useValues(marketingAttributionLogic)
+ const { setRevenueGoalId, setBreakdownBy } = useActions(marketingAttributionLogic)
const { dateFilter, compareFilter, shouldFilterTestAccounts } = useValues(marketingAnalyticsLogic)
- const { setDates, setCompareFilter } = useActions(marketingAnalyticsLogic)
+ const { setDates, setCompareFilter, setActiveTab, setSetupSection } = useActions(marketingAnalyticsLogic)
const dateRange = { date_from: dateFilter.dateFrom, date_to: dateFilter.dateTo }
const query: WebOverviewQuery = {
kind: NodeKind.WebOverviewQuery,
@@ -141,6 +153,63 @@ export function NewMarketingAnalyticsDashboard(): JSX.Element {
<AttributionTab />
</section>
)}
+ {featureFlags[FEATURE_FLAGS.MARKETING_ANALYTICS_ATTRIBUTION] && (
+ <section aria-label="Revenue" className="flex flex-col gap-4">
+ <h2 className="mb-0">Revenue</h2>
+ {currentTeamLoading || !currentTeam ? (
+ <LemonSkeleton className="h-40" />
+ ) : revenueQuery ? (
+ <>
+ <div className="flex flex-wrap items-center gap-2">
+ <DateFilter
+ dateFrom={dateFilter.dateFrom}
+ dateTo={dateFilter.dateTo}
+ onChange={setDates}
+ />
+ <LemonSelect
+ value={selectedRevenueGoalId}
+ onChange={(value) => value && setRevenueGoalId(value)}
+ options={revenueGoals.map((goal) => ({
+ value: goal.conversion_goal_id,
+ label: goal.conversion_goal_name,
+ }))}
+ data-attr="marketing-revenue-goal"
+ />
+ <LemonSelect
+ value={breakdownBy}
+ onChange={setBreakdownBy}
+ options={Object.values(MarketingAnalyticsAttributionBreakdown).map((value) => ({
+ value,
+ label: BREAKDOWN_LABELS[value],
+ }))}
+ data-attr="marketing-revenue-breakdown"
+ />
+ </div>
+ <p className="text-secondary mb-0">
+ Compare attributed value across models for one revenue goal at a time.
+ </p>
+ <AttributionTable
+ metric="revenue"
+ query={revenueQuery}
+ attachTo={marketingAnalyticsLogic}
+ />
+ </>
+ ) : (
+ <LemonBanner
+ type="info"
+ action={{
+ children: 'Review in Setup',
+ onClick: () => {
+ setSetupSection(SetupSection.CONVERSION_GOALS)
+ setActiveTab(MarketingAnalyticsTab.SETUP)
+ },
+ }}
+ >
+ Choose an event or action goal that sums an amount and mark it as Revenue in Setup.
+ </LemonBanner>
+ )}
+ </section>
+ )}
<Query
query={{
...CHANNEL_SOURCE_BREAKDOWN,
diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionChart.tsx b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionChart.tsx
index ee85fe7bf8ab..a0a230d78f79 100644
--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionChart.tsx
+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionChart.tsx
@@ -1,4 +1,5 @@
import clsx from 'clsx'
+import { useValues } from 'kea'
import { useMemo } from 'react'
import { LemonSkeleton } from '@posthog/lemon-ui'
@@ -6,7 +7,9 @@ import type { BarChartConfig, Series } from '@posthog/quill-charts'
import { BarChart } from '@posthog/quill-charts'
import { useChartConfig, useChartTheme } from 'lib/charts/hooks'
+import { formatCurrency } from 'lib/utils/currency'
import { humanFriendlyNumber } from 'lib/utils/numbers'
+import { teamLogic } from 'scenes/teamLogic'
import { AttributionMode, MarketingAnalyticsAttributionRow } from '~/queries/schema/schema-general'
@@ -49,27 +52,41 @@ export function AttributionChart({
models,
dimensionLabel,
loading,
+ metric = 'conversions',
}: {
rows: MarketingAnalyticsAttributionRow[]
models: AttributionMode[]
dimensionLabel: string
loading?: boolean
+ metric?: 'conversions' | 'revenue'
}): JSX.Element | null {
const theme = useChartTheme()
+ const { baseCurrency } = useValues(teamLogic)
// Rows arrive server-ordered by influenced conversions, so the slice is the top slice.
- const chartRows = useMemo(() => rows.slice(0, MAX_CHART_ROWS), [rows])
+ const chartRows = useMemo(() => {
+ const ranked =
+ metric === 'revenue'
+ ? [...rows].sort(
+ (a, b) =>
+ Math.max(...b.models.map((m) => m.conversionValue ?? 0)) -
+ Math.max(...a.models.map((m) => m.conversionValue ?? 0))
+ )
+ : rows
+ return ranked.slice(0, MAX_CHART_ROWS)
+ }, [rows, metric])
const config: BarChartConfig = useChartConfig(
() => ({
barLayout: 'grouped',
legend: { show: true, position: 'top' },
tooltip: {
- valueFormatter: (value: number) => humanFriendlyNumber(value, 1),
+ valueFormatter: (value: number) =>
+ metric === 'revenue' ? formatCurrency(value, baseCurrency) : humanFriendlyNumber(value, 1),
sortedByValue: true,
},
}),
- []
+ [metric, baseCurrency]
)
const series: Series[] = useMemo(
@@ -77,9 +94,13 @@ export function AttributionChart({
models.map((model, index) => ({
key: model,
label: MODEL_LABELS[model],
- data: chartRows.map((row) => row.models[index]?.conversions ?? 0),
+ data: chartRows.map(
+ (row) =>
+ (metric === 'revenue' ? row.models[index]?.conversionValue : row.models[index]?.conversions) ??
+ 0
+ ),
})),
- [models, chartRows]
+ [models, chartRows, metric]
)
// Only a settled empty result hides the card: collapsing while loading shoves the table upward.
@@ -89,10 +110,13 @@ export function AttributionChart({
return (
<div className="rounded border bg-surface-primary p-4">
- <h3 className="mb-0 text-base font-semibold">Conversions by attribution model</h3>
+ <h3 className="mb-0 text-base font-semibold">
+ {metric === 'revenue' ? 'Revenue by attribution model' : 'Conversions by attribution model'}
+ </h3>
<p className="mb-2 text-secondary">
- Each bar is the number of conversions a model credits to a {dimensionLabel.toLowerCase()}. Bars of equal
- height mean the models agree; different heights show where credit moves when the model changes.
+ Each bar is {metric === 'revenue' ? 'the revenue' : 'the number of conversions'} a model credits to a{' '}
+ {dimensionLabel.toLowerCase()}. Bars of equal height mean the models agree; different heights show where
+ credit moves when the model changes.
{rows.length > MAX_CHART_ROWS
? ` Showing the top ${MAX_CHART_ROWS} of ${rows.length} rows. The table below has all of them.`
: ''}
diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionTable.tsx b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionTable.tsx
index 9ed41d9dae54..c4223f68a24c 100644
--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionTable.tsx
+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/components/AttributionTab/AttributionTable.tsx
@@ -52,9 +52,11 @@ let uniqueNode = 0
export function AttributionTable({
query,
attachTo,
+ metric = 'conversions',
}: {
query: MarketingAnalyticsAttributionQuery
attachTo?: LogicWrapper | BuiltLogic
+ metric?: 'conversions' | 'revenue'
}): JSX.Element {
const [key] = useState(() => `MarketingAttribution.${uniqueNode++}`)
// Registered under the tab's shared collection so the filter bar's ReloadAll reaches this query.
@@ -222,7 +224,15 @@ export function AttributionTable({
]
}
- const columns = buildColumns()
+ const columns = buildColumns().map((group) => ({
+ ...group,
+ children:
+ metric === 'revenue'
+ ? group.children.filter(
+ (column) => column.key === 'breakdown_value' || String(column.key).endsWith('_value')
+ )
+ : group.children,
+ }))
if (responseError) {
return (
@@ -256,7 +266,13 @@ export function AttributionTable({
later in the journey, like signing up or paying, show how the models differ.
</LemonBanner>
)}
- <AttributionChart rows={rows} models={models} dimensionLabel={dimensionLabel} loading={responseLoading} />
+ <AttributionChart
+ metric={metric}
+ rows={rows}
+ models={models}
+ dimensionLabel={dimensionLabel}
+ loading={responseLoading}
+ />
<LemonTable
className="AttributionTable"
columns={columns}
diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAttributionLogic.test.ts b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAttributionLogic.test.ts
new file mode 100644
index 000000000000..f0fd003be33a
--- /dev/null
+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAttributionLogic.test.ts
@@ -0,0 +1,64 @@
+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'
+
+import { expectLogic } from 'kea-test-utils'
+
+import { teamLogic } from 'scenes/teamLogic'
+
+import { ConversionGoalFilter, NodeKind } from '~/queries/schema/schema-general'
+import { initKeaTests } from '~/test/init'
+import { PropertyMathType } from '~/types'
+
+import { marketingAttributionLogic } from './marketingAttributionLogic'
+
+it('restricts revenue queries to valid goals and drops a selection from the previous project', async () => {
+ initKeaTests()
+ const logic = marketingAttributionLogic()
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+ const revenue: ConversionGoalFilter = {
+ kind: NodeKind.EventsNode,
+ event: 'purchase',
+ conversion_goal_id: 'revenue',
+ conversion_goal_name: 'Purchases',
+ schema_map: {},
+ math: PropertyMathType.Sum,
+ math_property: 'amount',
+ counts_as_revenue: true,
+ }
+ const loadGoals = async (id: number, goals: ConversionGoalFilter[]): Promise<void> => {
+ await expectLogic(logic, () =>
+ teamLogic.actions.loadCurrentTeamSuccess({
+ ...MOCK_DEFAULT_TEAM,
+ id,
+ marketing_analytics_config: { conversion_goals: goals },
+ })
+ ).toFinishAllListeners()
+ }
+ await loadGoals(101, [
+ { ...revenue, conversion_goal_id: 'unmarked', counts_as_revenue: false },
+ { ...revenue, conversion_goal_id: 'missing-amount', math_property: undefined },
+ {
+ ...revenue,
+ conversion_goal_id: 'warehouse',
+ kind: NodeKind.DataWarehouseNode,
+ id: 'orders',
+ table_name: 'orders',
+ id_field: 'id',
+ timestamp_field: 'timestamp',
+ distinct_id_field: 'distinct_id',
+ },
+ revenue,
+ ])
+ expect(logic.values.revenueGoals).toEqual([revenue])
+ logic.actions.setRevenueGoalId('revenue')
+ logic.actions.setAllowMultipleConversionsPerVisitor(false)
+ expect(logic.values.revenueQuery).toMatchObject({
+ conversionGoalId: 'revenue',
+ allowMultipleConversionsPerVisitor: true,
+ })
+ await loadGoals(102, [{ ...revenue, conversion_goal_id: 'other-project' }])
+ expect(logic.values.revenueQuery?.conversionGoalId).toBe('other-project')
+ await loadGoals(103, [])
+ expect(logic.values.revenueQuery).toBeNull()
+ logic.unmount()
+})
diff --git a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAttributionLogic.ts b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAttributionLogic.ts
index 650038534e02..cb399f58f55a 100644
--- a/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAttributionLogic.ts
+++ b/frontend/src/scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAttributionLogic.ts
@@ -10,6 +10,7 @@ import {
} from '~/queries/schema/schema-general'
import { BaseMathType, IntervalType } from '~/types'
+import { revenueDisabledReason } from '../components/settings/conversionGoalFlags'
import { marketingAnalyticsLogic } from './marketingAnalyticsLogic'
import { marketingAnalyticsSettingsLogic } from './marketingAnalyticsSettingsLogic'
import { BREAKDOWN_LABELS, attributableConversionGoals } from './marketingBreakdown'
@@ -95,7 +96,11 @@ export interface marketingAttributionLogicValues {
pathTouchpointFilter: PathTouchpointFilter
pathsQuery: MarketingAnalyticsAttributionPathsQuery | null
query: MarketingAnalyticsAttributionQuery | null
+ revenueGoalId: string | null
+ revenueGoals: ConversionGoalFilter[]
+ revenueQuery: MarketingAnalyticsAttributionQuery | null
selectedGoalId: string | null
+ selectedRevenueGoalId: string | null
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -124,11 +129,20 @@ export interface marketingAttributionLogicActions {
setPathTouchpointFilter: (pathTouchpointFilter: PathTouchpointFilter) => {
pathTouchpointFilter: PathTouchpointFilter
}
+ setRevenueGoalId: (revenueGoalId: string) => {
+ revenueGoalId: string
+ }
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface marketingAttributionLogicMeta {
__keaTypeGenInternalSelectorTypes: {
+ revenueGoals: (attributableGoals: ConversionGoalFilter[]) => ConversionGoalFilter[]
+ selectedRevenueGoalId: (revenueGoalId: string | null, revenueGoals: ConversionGoalFilter[]) => string | null
+ revenueQuery: (
+ query: MarketingAnalyticsAttributionQuery | null,
+ selectedRevenueGoalId: string | null
+ ) => MarketingAnalyticsAttributionQuery | null
attributableGoals: (conversion_goals: ConversionGoalFilter[]) => ConversionGoalFilter[]
selectedGoalId: (conversionGoalId: string | null, attributableGoals: ConversionGoalFilter[]) => string | null
effectiveLookbackDays: (lookbackWindowDays: number | null, attribution_window_days: number) => number
@@ -178,6 +192,7 @@ export const marketingAttributionLogic = kea<marketingAttributionLogicType>([
],
})),
actions({
+ setRevenueGoalId: (revenueGoalId: string) => ({ revenueGoalId }),
setBreakdownBy: (breakdownBy: MarketingAnalyticsAttributionBreakdown) => ({ breakdownBy }),
setConversionGoalId: (conversionGoalId: string) => ({ conversionGoalId }),
setExcludeDirectTraffic: (excludeDirectTraffic: boolean) => ({ excludeDirectTraffic }),
@@ -190,6 +205,7 @@ export const marketingAttributionLogic = kea<marketingAttributionLogicType>([
setOptionsOpen: (optionsOpen: boolean) => ({ optionsOpen }),
}),
reducers({
+ revenueGoalId: [null as string | null, { setRevenueGoalId: (_, { revenueGoalId }) => revenueGoalId }],
breakdownBy: [
MarketingAnalyticsAttributionBreakdown.Channel as MarketingAnalyticsAttributionBreakdown,
{ setBreakdownBy: (_, { breakdownBy }) => breakdownBy },
@@ -226,6 +242,33 @@ export const marketingAttributionLogic = kea<marketingAttributionLogicType>([
],
}),
selectors({
+ revenueGoals: [
+ (s) => [s.attributableGoals],
+ (goals: ConversionGoalFilter[]): ConversionGoalFilter[] =>
+ goals.filter((goal) => goal.counts_as_revenue && !revenueDisabledReason(goal)),
+ ],
+ selectedRevenueGoalId: [
+ (s) => [s.revenueGoalId, s.revenueGoals],
+ (id: string | null, goals: ConversionGoalFilter[]): string | null =>
+ goals.find((goal) => goal.conversion_goal_id === id)?.conversion_goal_id ??
+ goals[0]?.conversion_goal_id ??
+ null,
+ ],
+ revenueQuery: [
+ (s) => [s.query, s.selectedRevenueGoalId],
+ (
+ query: MarketingAnalyticsAttributionQuery | null,
+ goalId: string | null
+ ): MarketingAnalyticsAttributionQuery | null =>
+ query && goalId
+ ? {
+ ...query,
+ conversionGoalId: goalId,
+ allowMultipleConversionsPerVisitor: true,
+ includeRevenue: true,
+ }
+ : null,
+ ],
attributableGoals: [
(s) => [s.conversion_goals],
// Annotated rather than passing `attributableConversionGoals` straight through: typegen
diff --git a/products/marketing_analytics/backend/hogql_queries/attribution_table_query_runner.py b/products/marketing_analytics/backend/hogql_queries/attribution_table_query_runner.py
index 9575619e0c60..5247455023fe 100644
--- a/products/marketing_analytics/backend/hogql_queries/attribution_table_query_runner.py
+++ b/products/marketing_analytics/backend/hogql_queries/attribution_table_query_runner.py
@@ -381,7 +381,19 @@ class MarketingAnalyticsAttributionQueryRunner(AttributionQueryRunnerBase[Market
),
# Server ordering only decides which rows make the page; the table re-sorts client side.
order_by=[
- ast.OrderExpr(expr=ast.Field(chain=[_INFLUENCED_CONVERSIONS]), order="DESC"),
+ ast.OrderExpr(
+ expr=ast.Call(
+ name="arrayMax",
+ args=[
+ ast.Array(
+ exprs=[ast.Field(chain=[f"{alias}_value"]) for alias in _ordered_weight_aliases()]
+ )
+ ],
+ )
+ if self.query.includeRevenue
+ else ast.Field(chain=[_INFLUENCED_CONVERSIONS]),
+ order="DESC",
+ ),
ast.OrderExpr(expr=ast.Field(chain=[_VISITORS]), order="DESC"),
],
limit=ast.Constant(value=(self.query.limit or DEFAULT_LIMIT) + PAGINATION_EXTRA),
diff --git a/products/marketing_analytics/backend/hogql_queries/test_attribution_table_query_runner.py b/products/marketing_analytics/backend/hogql_queries/test_attribution_table_query_runner.py
index 3f2808f56cd5..385e870f027b 100644
--- a/products/marketing_analytics/backend/hogql_queries/test_attribution_table_query_runner.py
+++ b/products/marketing_analytics/backend/hogql_queries/test_attribution_table_query_runner.py
@@ -146,6 +146,24 @@ class TestMarketingAnalyticsAttributionQueryRunner(ClickhouseTestMixin, BaseTest
)
return MarketingAnalyticsAttributionQueryRunner(query=query, team=self.team).calculate()
+ @parameterized.expand([(False, "frequent"), (True, "valuable")])
+ def test_revenue_ranking_precedes_row_limit(self, include_revenue: bool, expected: str) -> None:
+ for person, source, amount in [("a", "frequent", 1), ("b", "frequent", 1), ("c", "valuable", 1000)]:
+ create_person(team=self.team, distinct_ids=[person])
+ self._session(person, ONE_DAY_BEFORE, utm_source=source)
+ self._conversion(person, CONVERSION_AT, revenue=amount)
+ flush_persons_and_events()
+ query = MarketingAnalyticsAttributionQuery(
+ dateRange=DateRange(date_from="2023-01-01", date_to="2023-01-31"),
+ breakdownBy=MarketingAnalyticsAttributionBreakdown.SOURCE,
+ conversionGoalId=GOAL_ID,
+ properties=[],
+ includeRevenue=include_revenue,
+ limit=1,
+ )
+ response = MarketingAnalyticsAttributionQueryRunner(query=query, team=self.team).calculate()
+ assert response.results[0].breakdownValue == expected
+
@staticmethod
def _by_breakdown(response) -> dict[str, dict[AttributionMode, float]]:
"""{breakdown value: {model: conversions}} — the shape every weight assertion needs."""