Skip to content

Commit

Permalink
Merge pull request #38 from Springbok-Agency/new-sessionid
Browse files Browse the repository at this point in the history
session-key
  • Loading branch information
tessa-beijloos authored Dec 16, 2024
2 parents bdfe060 + 2703969 commit bee74a4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion macros/base_select.sql
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
) items
, property_id
, {{ ga4.unnest_key('event_params', 'ga_session_id', 'int_value', 'session_id') }}
, CAST(REGEXP_EXTRACT(COALESCE((select value.string_value from unnest(event_params) where key = 'ga_session_id'), ""), r'^GS\d\.\d\.(\d+)') AS INT64) as mp_session_id
, (select value.string_value from unnest(event_params) where key = 'ga_session_id') as session_id_string
, {{ ga4.unnest_key('event_params', 'page_location') }}
, {{ ga4.unnest_key('event_params', 'ga_session_number', 'int_value', 'session_number') }}
, COALESCE(
Expand Down
5 changes: 2 additions & 3 deletions models/staging/base/base_ga4__events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,9 @@ with source as (
),
renamed as (
select
{{ ga4.base_select_renamed() }},
COALESCE(session_id, mp_session_id) as session_id
{{ ga4.base_select_renamed() }}
from source
)

select * from renamed
qualify row_number() over(partition by event_date_dt, stream_id, user_pseudo_id, session_id, event_name, event_timestamp, to_json_string(ARRAY(SELECT params FROM UNNEST(event_params) AS params ORDER BY key))) = 1
qualify row_number() over(partition by event_date_dt, stream_id, user_pseudo_id, session_id, session_id_string, event_name, event_timestamp, to_json_string(ARRAY(SELECT params FROM UNNEST(event_params) AS params ORDER BY key))) = 1

0 comments on commit bee74a4

Please sign in to comment.