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

Associating sessions with GA4 properties for multi-property configuration #292

Closed shreveasaurus closed 7 months ago

shreveasaurus commented 7 months ago

In a setup with multiple properties, how can one link sessions to their originating GA4 property?

I've considered using the dim_ga4__sessions.device_web_info_hostname field, which records the hostname related to the event. Yet, I've noticed this field isn't consistently filled for all properties and sessions.

adamribaudo-velir commented 7 months ago

there should be a stream_id field that uniquely identifies the data stream. There is typically a 1:1 association between a web stream and a GA4 property. So it serves as a proxy for the property.

shreveasaurus commented 7 months ago

Ah, it was right there all along. Thanks for the helpful insight! That is indeed how the properties are currently configured so I'll go ahead and seed a GA4 property dimension table with the associated stream IDs for easy property filtering/aggregation. I really appreciate you taking the time to prevent me from doing something silly like extend the package to introduce a new column to pass the property ID through to the dim/fct models.