Skip to content

Commit 58e38f6

Browse files
author
jhnvdw
authored
Merge pull request #1 from jhnvdw/user_page_paths
Fix and new model
2 parents 025a550 + 35cbeee commit 58e38f6

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-- this query creates a list of unique events and parameters with the corresponding data types and the amount these event-parameter combinations occur in the GA4 property (only within the lookback period)
2+
SELECT
3+
event_name,
4+
params.key AS event_parameter_key,
5+
CASE
6+
WHEN params.value.string_value IS NOT NULL THEN 'string'
7+
WHEN params.value.int_value IS NOT NULL THEN 'int'
8+
WHEN params.value.double_value IS NOT NULL THEN 'double'
9+
WHEN params.value.float_value IS NOT NULL THEN 'float'
10+
END
11+
AS event_parameter_value,
12+
count(*) as amount
13+
FROM
14+
`{{ target.project }}.{{ target.schema }}.events_*`,
15+
UNNEST(event_params) AS params
16+
WHERE
17+
_TABLE_SUFFIX BETWEEN FORMAT_DATE("%Y%m%d", DATE_SUB(CURRENT_DATE(), INTERVAL {{ var('session_lookback_days') }} DAY))
18+
AND FORMAT_DATE("%Y%m%d", CURRENT_DATE())
19+
GROUP BY
20+
event_name,
21+
event_parameter_key,
22+
event_parameter_value
23+
ORDER BY
24+
event_name,
25+
event_parameter_key

models/math/user_page_paths.sql

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ first_value(page_location) over paths as first_path,
2424
last_value(page_location) over paths as last_path,
2525
lag(page_location) over paths as prev_path,
2626
lead(page_location) over paths as next_path,
27-
first_value(utm_source) as utm_source,
28-
first_value(utm_medium) as utm_medium,
29-
first_value(utm_campaign) as utm_campaign,
30-
first_value(utm_referrer) as utm_referrer,
27+
first_value(utm_source) over paths as utm_source,
28+
first_value(utm_medium) over paths as utm_medium,
29+
first_value(utm_campaign) over paths as utm_campaign,
30+
first_value(utm_referrer) over paths as utm_referrer,
3131
device_category,
3232
device_language,
3333
device_browser,

0 commit comments

Comments
 (0)