Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
optimize attribution report
Francis Cao5280fb4310ff
diff --git a/src/app/(main)/reports/create/ReportTemplates.tsx b/src/app/(main)/reports/create/ReportTemplates.tsxindex 9b4e21176..292b7322e 100644--- a/src/app/(main)/reports/create/ReportTemplates.tsx+++ b/src/app/(main)/reports/create/ReportTemplates.tsx@@ -1,10 +1,11 @@import Funnel from '@/assets/funnel.svg';+import Money from '@/assets/money.svg';import Lightbulb from '@/assets/lightbulb.svg';import Magnet from '@/assets/magnet.svg';-import Money from '@/assets/money.svg';import Path from '@/assets/path.svg';import Tag from '@/assets/tag.svg';import Target from '@/assets/target.svg';+import Network from '@/assets/network.svg';import { useMessages, useTeamUrl } from '@/components/hooks';import PageHeader from '@/components/layout/PageHeader';import Link from 'next/link';@@ -58,12 +59,12 @@ export function ReportTemplates({ showHeader = true }: { showHeader?: boolean })url: renderTeamUrl('/reports/revenue'),icon: <Money />,},- // {- // title: formatMessage(labels.attribution),- // description: formatMessage(labels.attributionDescription),- // url: renderTeamUrl('/reports/attribution'),- // icon: <Network />,- // },+ {+ title: formatMessage(labels.attribution),+ description: formatMessage(labels.attributionDescription),+ url: renderTeamUrl('/reports/attribution'),+ icon: <Network />,+ },];return (diff --git a/src/queries/sql/reports/getAttribution.ts b/src/queries/sql/reports/getAttribution.tsindex 62ad068a5..b35d50905 100644--- a/src/queries/sql/reports/getAttribution.ts+++ b/src/queries/sql/reports/getAttribution.ts@@ -261,13 +261,14 @@ async function clickhouseQuery(selectwe.${utmColumn} name,${currency ? 'sum(e.value)' : 'uniqExact(we.session_id)'} value- from events e- join model m- on m.session_id = e.session_id+ from model mjoin website_event weon we.created_at = m.created_atand we.session_id = m.session_id- ${currency ? '' : `where we.${utmColumn} != ''`}+ ${currency ? 'join events e on e.session_id = m.session_id' : ''}+ where we.website_id = {websiteId:UUID}+ and we.created_at between {startDate:DateTime64} and {endDate:DateTime64}+ ${currency ? '' : `and we.${utmColumn} != ''`}group by 1order by 2 desclimit 20`;@@ -311,6 +312,8 @@ async function clickhouseQuery(from events ejoin website_event weon we.session_id = e.session_id+ where we.website_id = {websiteId:UUID}+ and we.created_at between {startDate:DateTime64} and {endDate:DateTime64}group by e.session_id)`: `\nmodel AS (select e.session_id,@@ -318,7 +321,9 @@ async function clickhouseQuery(from events ejoin website_event weon we.session_id = e.session_id- where we.created_at < e.max_dt+ where we.website_id = {websiteId:UUID}+ and we.created_at between {startDate:DateTime64} and {endDate:DateTime64}+ and we.created_at < e.max_dtgroup by e.session_id)`;}@@ -333,16 +338,17 @@ async function clickhouseQuery(${getModelQuery(model)}select we.referrer_domain name,${currency ? 'sum(e.value)' : 'uniqExact(we.session_id)'} value- from events e- join model m- on m.session_id = e.session_id+ from model mjoin website_event weon we.created_at = m.created_atand we.session_id = m.session_id+ ${currency ? 'join events e on e.session_id = m.session_id' : ''}+ where we.website_id = {websiteId:UUID}+ and we.created_at between {startDate:DateTime64} and {endDate:DateTime64}${currency? ''- : `where referrer_domain != hostname+ : `and we.referrer_domain != hostnameand we.referrer_domain != ''`}group by 1@@ -368,13 +374,14 @@ async function clickhouseQuery(li_fat_id != '', ' LinkedIn Ads',twclid != '', 'Twitter Ads (X)','') name,${currency ? 'sum(e.value)' : 'uniqExact(we.session_id)'} value- from events e- join model m- on m.session_id = e.session_id+ from model mjoin website_event weon we.created_at = m.created_atand we.session_id = m.session_id- ${currency ? '' : `WHERE name != ''`}+ ${currency ? 'join events e on e.session_id = m.session_id' : ''}+ where we.website_id = {websiteId:UUID}+ and we.created_at between {startDate:DateTime64} and {endDate:DateTime64}+ ${currency ? '' : `and name != ''`}group by 1order by 2 desclimit 20