mirror of
https://github.com/umami-software/umami.git
synced 2026-02-15 10:05:36 +01:00
Added channel labels.
This commit is contained in:
parent
d81a7fec99
commit
fd4a405779
4 changed files with 38 additions and 19 deletions
|
|
@ -157,17 +157,17 @@ function getChannels(data: { domain: string; query: string; visitors: number }[]
|
||||||
direct: 0,
|
direct: 0,
|
||||||
referral: 0,
|
referral: 0,
|
||||||
affiliate: 0,
|
affiliate: 0,
|
||||||
|
email: 0,
|
||||||
sms: 0,
|
sms: 0,
|
||||||
organic_search: 0,
|
organicSearch: 0,
|
||||||
organic_social: 0,
|
organicSocial: 0,
|
||||||
organic_email: 0,
|
organicShopping: 0,
|
||||||
organic_shopping: 0,
|
organicVideo: 0,
|
||||||
organic_video: 0,
|
paidAds: 0,
|
||||||
paid_ads: 0,
|
paidSearch: 0,
|
||||||
paid_search: 0,
|
paidSocial: 0,
|
||||||
paid_social: 0,
|
paidShopping: 0,
|
||||||
paid_shopping: 0,
|
paidVideo: 0,
|
||||||
paid_video: 0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const match = (value: string) => {
|
const match = (value: string) => {
|
||||||
|
|
@ -184,23 +184,23 @@ function getChannels(data: { domain: string; query: string; visitors: number }[]
|
||||||
const prefix = /utm_medium=(.*cp.*|ppc|retargeting|paid.*)/.test(query) ? 'paid' : 'organic';
|
const prefix = /utm_medium=(.*cp.*|ppc|retargeting|paid.*)/.test(query) ? 'paid' : 'organic';
|
||||||
|
|
||||||
if (SEARCH_DOMAINS.some(match(domain)) || /utm_medium=organic/.test(query)) {
|
if (SEARCH_DOMAINS.some(match(domain)) || /utm_medium=organic/.test(query)) {
|
||||||
channels[`${prefix}_search`] += visitors;
|
channels[`${prefix}Search`] += visitors;
|
||||||
} else if (
|
} else if (
|
||||||
SOCIAL_DOMAINS.some(match(domain)) ||
|
SOCIAL_DOMAINS.some(match(domain)) ||
|
||||||
/utm_medium=(social|social-network|social-media|sm|social network|social media)/.test(query)
|
/utm_medium=(social|social-network|social-media|sm|social network|social media)/.test(query)
|
||||||
) {
|
) {
|
||||||
channels[`${prefix}_social`] += visitors;
|
channels[`${prefix}Social`] += visitors;
|
||||||
} else if (EMAIL_DOMAINS.some(match(domain)) || /utm_medium=(.*e[-_ ]?mail.*)/.test(query)) {
|
} else if (EMAIL_DOMAINS.some(match(domain)) || /utm_medium=(.*e[-_ ]?mail.*)/.test(query)) {
|
||||||
channels.organic_email += visitors;
|
channels.email += visitors;
|
||||||
} else if (
|
} else if (
|
||||||
SHOPPING_DOMAINS.some(match(domain)) ||
|
SHOPPING_DOMAINS.some(match(domain)) ||
|
||||||
/utm_campaign=(.*(([^a-df-z]|^)shop|shopping).*)/.test(query)
|
/utm_campaign=(.*(([^a-df-z]|^)shop|shopping).*)/.test(query)
|
||||||
) {
|
) {
|
||||||
channels[`${prefix}_shopping`] += visitors;
|
channels[`${prefix}Shopping`] += visitors;
|
||||||
} else if (VIDEO_DOMAINS.some(match(domain)) || /utm_medium=(.*video.*)/.test(query)) {
|
} else if (VIDEO_DOMAINS.some(match(domain)) || /utm_medium=(.*video.*)/.test(query)) {
|
||||||
channels[`${prefix}_video`] += visitors;
|
channels[`${prefix}Video`] += visitors;
|
||||||
} else if (PAID_AD_PARAMS.some(match(query))) {
|
} else if (PAID_AD_PARAMS.some(match(query))) {
|
||||||
channels.paid_ads += visitors;
|
channels.paidAds += visitors;
|
||||||
} else if (/utm_medium=(referral|app|link)/.test(query)) {
|
} else if (/utm_medium=(referral|app|link)/.test(query)) {
|
||||||
channels.referral += visitors;
|
channels.referral += visitors;
|
||||||
} else if (/utm_medium=affiliate/.test(query)) {
|
} else if (/utm_medium=affiliate/.test(query)) {
|
||||||
|
|
|
||||||
|
|
@ -281,6 +281,20 @@ export const labels = defineMessages({
|
||||||
firstSeen: { id: 'label.first-seen', defaultMessage: 'First seen' },
|
firstSeen: { id: 'label.first-seen', defaultMessage: 'First seen' },
|
||||||
properties: { id: 'label.properties', defaultMessage: 'Properties' },
|
properties: { id: 'label.properties', defaultMessage: 'Properties' },
|
||||||
channels: { id: 'label.channels', defaultMessage: 'Channels' },
|
channels: { id: 'label.channels', defaultMessage: 'Channels' },
|
||||||
|
direct: { id: 'label.direct', defaultMessage: 'Direct' },
|
||||||
|
referral: { id: 'label.referral', defaultMessage: 'Referral' },
|
||||||
|
affiliate: { id: 'label.affiliate', defaultMessage: 'Affiliate' },
|
||||||
|
email: { id: 'label.email', defaultMessage: 'Email' },
|
||||||
|
sms: { id: 'label.sms', defaultMessage: 'SMS' },
|
||||||
|
organicSearch: { id: 'label.organic-search', defaultMessage: 'Organic search' },
|
||||||
|
organicSocial: { id: 'label.organic-social', defaultMessage: 'Organic social' },
|
||||||
|
organicShopping: { id: 'label.organic-shopping', defaultMessage: 'Organic shopping' },
|
||||||
|
organicVideo: { id: 'label.organic-video', defaultMessage: 'Organic video' },
|
||||||
|
paidAds: { id: 'label.paid-ads', defaultMessage: 'Paid ads' },
|
||||||
|
paidSearch: { id: 'label.paid-search', defaultMessage: 'Paid search' },
|
||||||
|
paidSocial: { id: 'label.paid-social', defaultMessage: 'Paid social' },
|
||||||
|
paidShopping: { id: 'label.paid-shopping', defaultMessage: 'Paid shopping' },
|
||||||
|
paidVideo: { id: 'label.paid-video', defaultMessage: 'Paid video' },
|
||||||
});
|
});
|
||||||
|
|
||||||
export const messages = defineMessages({
|
export const messages = defineMessages({
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,16 @@ import { useMessages } from '@/components/hooks';
|
||||||
export function BrowsersTable(props: MetricsTableProps) {
|
export function BrowsersTable(props: MetricsTableProps) {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
|
const renderLabel = ({ x }) => {
|
||||||
|
return formatMessage(labels[x]);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MetricsTable
|
<MetricsTable
|
||||||
{...props}
|
{...props}
|
||||||
title={formatMessage(labels.channels)}
|
title={formatMessage(labels.channels)}
|
||||||
type="channel"
|
type="channel"
|
||||||
|
renderLabel={renderLabel}
|
||||||
metric={formatMessage(labels.visitors)}
|
metric={formatMessage(labels.visitors)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
`
|
`
|
||||||
select
|
select
|
||||||
referrer_domain as domain,
|
referrer_domain as domain,
|
||||||
referrer_query as query,
|
referrer_query as query,
|
||||||
count(*) as visitors
|
count(distinct session_id) as visitors
|
||||||
from website_event
|
from website_event
|
||||||
where website_id = {websiteId:UUID}
|
where website_id = {websiteId:UUID}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue