SELECT *
FROM `business-metric.analytics_319368526.events_*`
WHERE event_name = 'user_data_event'
LIMIT 2
SELECT *
FROM `business-metric.analytics_319368526.events_*`
WHERE event_name = 'user_data_event' and event_params.key = 'source'
and event_params.value.string_value = 'yandex'
SELECT
event_name, param
FROM `business-metric.analytics_319368526.events_*`,
UNNEST(event_params) as param
WHERE event_name = 'user_data_event' and param.key = 'cid_ga4'
limit 5
SELECT count(event_name) as count_event, param.key as event_parameter,param.value.string_value as source
FROM `business-metric.analytics_319368526.events_*`,
UNNEST(event_params) as param
WHERE event_name = 'user_data_event' and param.key = 'source'
and param.value.string_value = 'yandex'
group by param.key,param.value.string_value
SELECT distinct param.value.string_value as source
FROM `business-metric.analytics_319368526.events_*`,
UNNEST(event_params) as param
WHERE param.key = 'source'
SELECT event_name, event_timestamp, user_pseudo_id,
(SELECT value.string_value FROM UNNEST(event_params)
WHERE key = 'source') AS source,
(SELECT value.string_value FROM UNNEST(event_params)
WHERE key = 'medium') AS medium
FROM `business-metric.analytics_319368526.events_*`
WHERE event_name = 'user_data_event'
SELECT event_name, event_timestamp, user_pseudo_id,
(SELECT value.string_value FROM UNNEST(event_params)
WHERE key = 'source') AS source,
(SELECT value.string_value FROM UNNEST(event_params)
WHERE key = 'medium') AS medium,
(SELECT value.string_value FROM UNNEST(user_properties)
WHERE key = 'client_id_ga4') AS cid,
FROM `business-metric.analytics_319368526.events_*`
WHERE event_name = 'user_data_event'
select distinct event_name from `business-metric.analytics_319368526.events_*`
select distinct params
from (
select params.key as params
from `business-metric.analytics_319368526.events_*`,
unnest (event_params) as params
where event_name in( 'first_visit', 'user_data_event', 'click_phone_number'))
select distinct params,string, value
from (
select params.key as params,params.value.string_value as string,params.value.int_value as value
from `business-metric.analytics_319368526.events_*`,
unnest (event_params) as params
where event_name in( 'first_visit', 'user_data_event', 'click_phone_number'))
select distinct params,string, value
from (
select params.key as params,params.value.string_value as string,params.value.int_value as value
from `business-metric.analytics_319368526.events_*`,
unnest (event_params) as params
where event_name in( 'first_visit', 'user_data_event', 'click_phone_number'))
where params = 'element_location'
select distinct properties
from (
select properties.key as properties
from `business-metric.analytics_319368526.events_*`,
unnest (user_properties) as properties
where event_name in( 'first_visit', 'user_data_event', 'click_phone_number'))
select distinct properties, string, value
from (
select properties.key as properties,properties.value.string_value as string,properties.value.int_value as value
from `business-metric.analytics_319368526.events_*`,
unnest (user_properties) as properties
where event_name in( 'first_visit', 'user_data_event', 'click_phone_number'))
WITH flat_table AS (
SELECT
user_pseudo_id,
PARSE_DATE('%Y%m%d',event_date) AS date,
user_first_touch_timestamp,
device.category,
event_name,
traffic_source.source AS source,
traffic_source.medium AS medium,
CONCAT(traffic_source.source,' / ',traffic_source.medium) AS source_medium,
(SELECT value.string_value FROM UNNEST(user_properties)
WHERE key = 'client_id_ga4') AS cid,
(SELECT value.string_value FROM UNNEST(event_params)
WHERE key = 'page_referrer') AS page_referrer ,
(SELECT value.int_value FROM UNNEST(event_params)
WHERE key = 'ga_session_id') AS ga_session_id ,
(SELECT value.string_value FROM UNNEST(event_params)
WHERE key = 'page_title') AS page_title,
(SELECT value.string_value FROM UNNEST(event_params)
WHERE key = 'element_location') AS element_location,
device.browser,
geo.city,
platform
from `business-metric.analytics_319368526.events_*`
where event_name in( 'first_visit', 'user_data_event', 'click_phone_number')
)
SELECT * from flat_table
SELECT
*
FROM
flat_table
where element_location is not null