Update Google analytics code to use new GA4 trackers #118
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.
Purpose
Fix #108 . This is a very simplistic migration for coarse-grained pageview tracking of visits to TIS. It does not use any advanced features, such as feature-level event based analytics.
https://developers.google.com/analytics/devguides/migration/ua/analyticsjs-to-gtagjs
Preliminary evaluation suggests that neither TIS nor MIS are presently using the GA integration feature (no tracker defined via admin panel). Thus we expect minimal impact on existing deployments. The prior google analytics version stopped collecting data in July 2023, hence no old sites will lose the ability to collect analytics if this code is changed.
Deployment Notes
Due to user privacy concerns, we should take care to minimize sensitive data collection where possible.
We have created a GA4 property with many default features explicitly turned off. We have deauthorized third party sharing, google support access, "user-provided data capabilities", scrolling, form, and file download tracking, and ad integrations. To deploy this consistently, the UM terraform repos will need to be modified to include the GA tracking code whenever the config file is regenerated (for a new server).
Testing notes
It typically takes 12-72 hr for analytics events to become visible in the GA dashboard. Browser extensions such as ublock origin may interfere with testing this feature.
Per UM team policy, UM PIs have been given admin-level access to the TIS GA project as contacts of record.
No events are sent for navigation to sub-pages. Preliminary evaluation suggests that CG uses hash-based routes, rather than the JS history manipulation API; this style of URL manipulation is not automatically captured by the analytics tool.