mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Add UTM pageview metrics to API
This commit is contained in:
parent
16046a50a4
commit
92b009fa1e
3 changed files with 88 additions and 1 deletions
38
queries/analytics/pageview/getPageviewParams.js
Normal file
38
queries/analytics/pageview/getPageviewParams.js
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { parseFilters, rawQuery } from 'lib/queries';
|
||||
|
||||
export function getPageviewParams(
|
||||
param,
|
||||
website_id,
|
||||
start_at,
|
||||
end_at,
|
||||
column,
|
||||
table,
|
||||
filters = {},
|
||||
) {
|
||||
const params = [param, website_id, start_at, end_at];
|
||||
const { pageviewQuery, sessionQuery, eventQuery, joinSession } = parseFilters(
|
||||
table,
|
||||
column,
|
||||
filters,
|
||||
params,
|
||||
);
|
||||
|
||||
return rawQuery(
|
||||
`select * from (
|
||||
select
|
||||
url, split_part(split_part(url, concat($1, '='), 2), '&', 1) param
|
||||
from
|
||||
pageview
|
||||
${joinSession}
|
||||
${pageviewQuery}
|
||||
${joinSession && sessionQuery}
|
||||
${eventQuery}
|
||||
where
|
||||
${table}.website_id=$2 and ${table}.created_at between $3 and $4
|
||||
group by 1, 2
|
||||
order by 2 desc
|
||||
) q
|
||||
where q.param <> ''`,
|
||||
params,
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue