Event Parameters
Automated and robust extraction of the event_params
nested object into correctly-typed BigQuery columns is one of the key benefits of using Decode GA4. There are a number of available options which give fine-grained control of the precise behaviour.
Options
To set these options, simply add them to the options
configuration JSON object. All of these options can be omitted from the options
JSON object, in which case all default and observed event_param
names will be converted into correctly-typed sub-columns of the output event_param
struct.
NAME | VALUE | Details |
---|---|---|
include_event_params_profile | BOOLEAN | [Optional] Flag to determine whether to include the observed event_param values contained in the event_profile .Default is true |
default_event_params_id | STRING | [Optional] ID of the UDF containing the default event_param values and types in JSON format. Default is decode-ga4.region_id.default_event_params . |
custom_event_params_id | STRING | [Optional] ID of the UDF containing additional custom event_param values and types in JSON format. |
exclude_event_params_list | ARRAY<STRING> | [Optional] List of event_param names to be excluded as sub-columns in the output struct. |
Default and Custom Event Params
The default event_param
values and data types are taken from the Google documentation. These may be added to over time, but existing event_param
names and data types will not change.
In order to override the default event_param
names and data types with a custom set, simply create your own User Defined Function (UDF) which returns JSON in the below schema, and set the default_event_params_id
to the ID of the UDF.
In order to use an additional custom set of event_param
names and data types, simply create your own User Defined Function (UDF) which returns JSON in the below schema, and set the custom_event_params_id
to the ID of the UDF.
Data type can be either string
, integer
or float
.
[
{"name": "event_param_name_x", "data_type": "string"},
{"name": "event_param_name_y", "data_type": "integer"},
{"name": "event_param_name_z", "data_type": "float"}
]
The template DDL to create an additional custom set of event parameters would therefore be:
CREATE OR REPLACE FUNCTION `project_id.dataset_id.custom_event_params_name`
AS (
JSON """[
{"name": "event_param_name_x", "data_type": "string"},
{"name": "event_param_name_y", "data_type": "integer"},
{"name": "event_param_name_z", "data_type": "float"}
]"""
)
Note that the options
JSON would then need the custom_event_params_id
= project_id.dataset_id.custom_event_params_name
option to be set to ensure that the custom default event_param
names and expected data types are included in the output event_param
struct. If any values are included in the default/custom parameters and the exclude_event_params_list
, they will be excluded from the output event_param
struct.