User Properties
Decode GA4 will also automate extraction of the user_properties
nested object into correctly-typed BigQuery columns. There are no standard default user_properties
, so the custom_user_properties_id
is used to set any specfically required values and data types.
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 user property names in the user_properties
nested object will be converted into correctly-typed sub-columns of the output user_property
struct.
NAME | VALUE | Details |
---|---|---|
include_user_properties_profile | BOOLEAN | [Optional] Flag to determine whether to include the observed user_property values contained in the event_profile .Default is true |
custom_user_properties_id | STRING | [Optional] ID of the UDF containing a custom set of user_property values and types in JSON format. |
exclude_user_properties_list | ARRAY<STRING> | [Optional] List of user_property names to be excluded as sub-columns in the output struct. |
Examples
Since there are no default user_properties
, in order to set the default user_property
names and data types simply create your own User Defined Function (UDF) which returns JSON in the below schema, and set the custom_user_properties_id
to the ID of the UDF.
Data type can be either string
, integer
or float
.
[
{"name": "user_property_name_x", "data_type": "string"},
{"name": "user_property_name_y", "data_type": "integer"},
{"name": "user_property_name_z", "data_type": "float"}
]
The template DDL to create this function would therefore be:
CREATE OR REPLACE FUNCTION `project_id.dataset_id.custom_user_properties_name`
AS (
JSON """[
{"name": "user_property_name_x", "data_type": "string"},
{"name": "user_property_name_y", "data_type": "integer"},
{"name": "user_property_name_z", "data_type": "float"}
]"""
)
Note that the options
JSON would then need the default_user_properties_id
= project_id.dataset_id.custom_user_properties_name
option to be set to ensure that the custom default user_properties
names and expected data types are included in the output user_property
struct.