This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FIRST_VALUE( | |
(SELECT | |
value.string_value | |
FROM | |
UNNEST(event_params) | |
WHERE | |
key = 'name_of_traffic_source_parameter' | |
--source, medium, campaign, content, term, campaign_id | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LAST_VALUE( | |
(SELECT | |
value.string_value --value.int_value, value.float_value, value.double_value | |
FROM | |
UNNEST(event_params) | |
WHERE | |
key = 'name_of_event_parameter_to_use_as_dimension' | |
) | |
IGNORE nulls | |
) OVER ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION `YOUR_PROJECT.YOUR_DATASET.GA4_parameter_value_and_type`( | |
parameter_key_to_be_queried STRING, | |
event_params ARRAY<STRUCT<key STRING, | |
value STRUCT< | |
string_value STRING, | |
int_value INT64, | |
float_value FLOAT64, | |
double_value FLOAT64 | |
> | |
> |