Skip to content

Tracking updates#26

Merged
Xykon merged 2 commits into
mainfrom
tracking_updates
Jun 17, 2026
Merged

Tracking updates#26
Xykon merged 2 commits into
mainfrom
tracking_updates

Conversation

@Xykon

@Xykon Xykon commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

This pull request enhances and generalizes analytics integration in the documentation site. It introduces flexible support for multiple analytics providers (GA4/gtag, Google Tag Manager, and GA4 tag IDs) via environment variables, and improves how analytics IDs are handled and normalized. The cookie consent banner is also updated to display when any analytics integration is enabled.

Analytics integration and configuration:

  • Added _env_id function in conf.py to normalize analytics environment variables, treating empty strings and common "off" values as disabled.
  • Updated the Sphinx html_context in conf.py to support GA_MEASUREMENT_ID, GTM_CONTAINER_ID, and GA4_TAG_ID environment variables, using the new normalization function.

Template and loader improvements:

  • Refactored _templates/layout.html to support loading analytics scripts for GA4/gtag, GTM, and GA4 tag IDs, enabling them based on the provided environment variables. [1] [2]
  • Modified the cookie consent banner logic in _templates/layout.html to display if any analytics integration is enabled, not just GA4.

Copilot AI review requested due to automatic review settings June 17, 2026 10:26
@Xykon
Xykon merged commit 6a35e9b into main Jun 17, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR generalizes the documentation site’s analytics integration by supporting multiple Google analytics entry points (GA4/gtag, GTM, and alternate GA4 tag IDs) and updating the cookie-consent banner to appear whenever any analytics integration is enabled.

Changes:

  • Added _env_id() in conf.py to normalize analytics-related environment variables and expose GA_MEASUREMENT_ID, GTM_CONTAINER_ID, and GA4_TAG_ID via html_context.
  • Refactored _templates/layout.html to conditionally load gtag and/or GTM based on the provided IDs and to treat analytics as enabled when either is configured.
  • Updated the cookie consent banner condition so it displays for any enabled analytics integration (not just GA4 measurement ID).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
conf.py Normalizes analytics env vars and adds additional analytics IDs to html_context.
_templates/layout.html Loads analytics scripts based on available IDs and broadens cookie banner enablement logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread conf.py
Comment on lines +9 to +19
def _env_id(name):
"""Return a normalized analytics ID from the environment.

Treats empty strings and literal 'none'/'null'/'undefined' as disabled.
"""
value = os.environ.get(name, "")
if value is None:
return ""

text = str(value).strip()
return "" if text.lower() in ("", "none", "null", "undefined") else text
@Xykon
Xykon deleted the tracking_updates branch July 14, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants