-
Identifying session-level traffic sources in BigQuery using CASE statements
In the process of identifying session-level traffic sources in GA4 data within BigQuery, you’ve noticed that the traffic_source variables relate to the traffic source that initially acquired the user, not necessarily the most current one. Currently, you can track traffic from marketing channels by using utm tags. However, for channels such as direct, organic search, and referral, you’re seeking an alternative approach because these don’t use utm tags. If the page_location does not have utm tags and the event_params contain a referral field, then you know where the traffic originated.
You’ve written a query to extract utm values from the page location and place them in new columns. For the case of organic search, you use a CASE statement that sets utm_medium as ‘organic’ and utm_source as the referral site.
Essentially, you’re trying to achieve this:
CASE WHEN A = 1 THEN B = 'apple' AND C = 'fruit' END
You’re unsure if this kind of multi-condition CASE statement is feasible in BigQuery, is that correct?
Log in to reply.