Velir / dbt-ga4

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

fix cpc classification and add test #306

Closed dgitis closed 8 months ago

dgitis commented 8 months ago

Description & motivation

Resolves #302

Google has started sometimes setting source and medium values to google / organic when a visitor clicks an ad.

This breaks the code that we use to fix google / cpc source/medium values that are mis-attributed to google / organic in the stg_ga4__events file.

This PR fixes that issue and adds a test to detect when it might happens again.

Checklist

dgitis commented 8 months ago

@cfrye2 I've just published a branch with your fix and added a test.

Do you still have a client that's getting cpc assigned to organic?

If so, can you copy this file into your tests folder and run dbt test --select page_location_with_gclid_is_cpc?

I haven't been able to verify that this test fails when it should.

dgitis commented 8 months ago

I just confirmed with @cfrye2 that the test with original_page_location now fails when it is supposed to.