Velir / dbt-ga4

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

fix fct_ga4__pages model and add tests to catch similar issues #295

Closed dgitis closed 8 months ago

dgitis commented 8 months ago

Description & motivation

The addition of page_engagement_key which is built from the page_referrer where page_view events are concerned was causing multiple rows with the same page_location and event_date_dt in the first CTE.

This PR adds a second aggregation in the second CTE to eliminate this redundancy and adds tests to the model to catch these issues in the future.

The fct_ga4__pages model will need a full refresh when upgrading to a version containing these changes as the new tests will trigger an error.

Resolves #274

Checklist

adamribaudo-velir commented 8 months ago

Looks like the unique test can fail when there is a page with the same page location but different page titles (not uncommon for translated content)

dgitis commented 8 months ago

This latest version removes page_path and page_title from the fct_ga4__pages model which will help this model pass its uniqueness test.