Draft
Add optional GA4 page-view tracking to API home page with env-based configuration#54
Conversation
Copilot
AI
changed the title
[WIP] Add Google Analytics to track global page views
Add optional GA4 page-view tracking to API home page with env-based configuration
Aug 1, 2026
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.
This issue asks for Google Analytics integration to capture page views and enable geography reporting, plus maintainers’ setup documentation. This PR adds GA4 instrumentation to the served home page and wires deployment/runtime configuration so tracking can be enabled in production without code changes.
Runtime integration (API home page)
api/app.pynow readsOSMSG_GA_MEASUREMENT_IDviaget_ga_measurement_id().home()passesga_measurement_idinto the template context.Conditional GA4 script injection
api/templates/home.htmlconditionally renders the standardgtag.jssnippet only when a measurement ID is configured.Deployment + local config plumbing
OSMSG_GA_MEASUREMENT_IDpassthrough in:infra/docker-compose.yml(apiservice)docker-compose.yml(apiservice).env.exampleinfra/.env.exampleMaintainer documentation
docs/infra.mdnow documents how to enable/disable GA4 viaOSMSG_GA_MEASUREMENT_IDfor deployed environments.Focused API coverage
tests/test_api.pyadds checks for:get_ga_measurement_id)