Session id
Session id is a unique identifier of the session. By default it's a combination of:
- user_pseudo_id (aka client_id)
- ga_session_id (the value from
event_params
with keyga_session_id
)
Each event during the session has the same session_id.
warning
It's possible that session_id could be not unique. The most common case is if events from the session are split between different days and you process the sessions only for one day per Dataform run. In this case, you could have the same session_id for different days.
To generate session_id
the package uses getSqlSessionId helper function.
But you could change the logic of session_id
generation and provide your own SQL code, like this:
const sessions = new ga4.Session(sessionConfig);sessions.getSqlUniqueId = () => { return `FARM_FINGERPRINT(CONCAT((select value.int_value from unnest(event_params) where key = 'ga_session_id'), user_pseudo_id)) as session_id`;};
If you want to change session_id
don't forget to add session_id
alias ("as session_id" at the end) to your custom SQL code.