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

Screen Resolution #309

Closed efrazier closed 3 months ago

efrazier commented 3 months ago

HI Guys, Not so much an issue as a question. Have you had many questions from people about this param missing from GA4's BigQuery export? From the #measure slack group it seems like the standard response is to add a custom dim to collect that via GTM/JS etc, but that doesn't account for historical data of course.

We do have various device info fields to use however and it seems to me like a community project could work to maintain a device to screen res table. What I have found so far is very limited in comparison to real world data. For example, if I do a query in the GA4 UI which does have screen resolution, I end up with a lot of unique values, many more than the 150 or so values I see from some online tables re Googling that. One point that is true regardless, you can only get max resolution this way, not the browser window size which still points to a custom dim as the way.

This seems, maybe a little relevant to your project since given that base data, it would be pretty easy then to fill in those values for users of this project. Just wondering on your thoughts.

Thanks, Eric

dgitis commented 3 months ago

The issue that I see is that the browser window size can't be calculated from the screen resolution because it changes based on how large the window size is (desktop), browser chrome and plugins (desktop and mobile), browser window for browsers embedded in apps to appear as apps (mobile), and the use of dev tools and emulators (desktop and mobile).

With all of those issues, I don't think a window size calculation is worth implementing as a core feature. I'm not aware of anyone else asking for it and we do support custom dimensions if someone chooses to implement it (but, obviously with no historical backfill).

Please correct me if I'm wrong about window size issues.

It's trivial to override the stg_ga4__events model and add in a step that calculates window size if it doesn't already exist. Let me know if you any questions about how to do that.

efrazier commented 3 months ago

Thanks very much for your reply. Yes, we resolved on just collecting the window size as a dimension. It was an unusual request for me as well, but it was interesting to read about the issues with collecting all sorts of device data, especially from iOS devices and it seems that has been going on for a number of years. This is in particular with Google Analytics. It sounds like some custom JS in GTM etc is the best path for any of that data vs depending on UA/GA4 defaults.

willbryant commented 3 months ago

I could be wrong but I believe that this problem is normally solved using device information databases + the device ID already collected, not by using JS to inspect the browser window.

dgitis commented 3 months ago

Another thing to be careful about with the more privacy-aware browsers is that some of them will fake data to prevent fingerprinting. I've seen this with page load APIs sending impossible values like millions of seconds load time or negative load times.

Will's solution is quite elegant.

I'm going to close this issue to keep things nice and tidy, but feel free to keep commenting and open it if you need.