Repository navigation
Add GA4 usage collection and summary report - #66
Merged
Merged
Conversation
GA4 purges user- and event-level data after its retention period, so long-term usage trends are lost unless the aggregate counts are copied out. ga4_usage_collect.py stores daily and monthly sums (traffic, hosts, countries, cities, sources, pages, viewed terms, events, load times) as TSV in VFB_reporting_results/analytics/ga4; ga4_usage_summary.py builds usage_report.md from those files alone. Only summed counts are kept: no user ids, and city rows need at least 5 users in a month.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Two new scripts in
src/.ga4_usage_collect.pypulls aggregate counts from the virtualflybrain.org GA4 property and writes them as TSV toVFB_reporting_results/analytics/ga4/.ga4_usage_summary.pybuildsusage_report.mdfrom those files alone.requirements.txtgainsgoogle-auth.Why
GA4 purges user- and event-level data at the end of its retention period, so long-term usage trends are lost unless the aggregate counts are copied out. Only summed counts are stored. No user ids are requested, GA4 never exposes IP addresses, and city rows are monthly with a floor of 5 users.
How to test
Set
GA4_SERVICE_ACCOUNT_KEY_PATHto a key with Viewer access on property 375054915, then runpython ga4_usage_collect.pyfollowed bypython ga4_usage_summary.pyfromsrc/. A default run pulls the last 4 days plus the current month.--start 2023-05-01backfills and--tableslimits the run.Follow-ups
Event parameters are invisible until custom dimensions are registered on the property. The viewer sends no search event, so typed search terms are not captured.