Velir / dbt-ga4

dbt Package for modeling raw data exported by Google Analytics 4. BigQuery support, only.
MIT License
289 stars 128 forks source link

Add specified user properties to event models #320

Open adamribaudo-velir opened 2 months ago

adamribaudo-velir commented 2 months ago

We allow users to list out specific user properties which are then added to this model: https://github.com/Velir/dbt-ga4/blob/main/models/staging/stg_ga4__user_properties.sql

However, it would be useful and inexpensive to include these user properties in all event models.

We perform a similar operation with custom event properties which are defined in the project.yml and then included in the event models with this code block:

 {% if var("default_custom_parameters", "none") != "none" %}
        {{ ga4.stage_custom_parameters( var("default_custom_parameters") )}}
      {% endif %}

Which uses this macro: https://github.com/Velir/dbt-ga4/blob/main/macros/stage_custom_parameters.sql

A similar 'stag user properties' macro could be created to accomplish the same thing for user properties.