From bcbe3ca4b5e478a6ba6f17b2c5a820330e4eabf5 Mon Sep 17 00:00:00 2001 From: Jon Froehlich Date: Sun, 21 Jun 2026 14:47:47 -0700 Subject: [PATCH] fix(analytics): migrate to native GA4 gtag.js, drop dead UA tag (#855) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Production was firing native GA4 (G-M18PCH55ZP) only indirectly: the inline Universal Analytics snippet loaded analytics.js, which chain-loaded the GA4 gtag via a console-side "connected site tag" (visible as gtag/js?...&_slc=1 initiated from analytics.js in DevTools). That bridge rides on the retired UA library and a linkage that lives only in the GA admin console, not in the repo — so GA4 would silently stop if the legacy machinery is removed. Replace the UA analytics.js/UA-79723676-1 snippet in base.html with the official native gtag.js snippet for G-M18PCH55ZP. GA4 now loads directly, version-controlled, with no dependency on the deprecated UA path. Keeps the {% if debug %} gate (prod-only). Removing the UA snippet also kills the chain trigger, so there is no double-counting. Bump to 2.16.2. Co-Authored-By: Claude Opus 4.8 (1M context) --- makeabilitylab/settings.py | 4 ++-- website/templates/website/base.html | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/makeabilitylab/settings.py b/makeabilitylab/settings.py index 4594263d..3cde7f45 100644 --- a/makeabilitylab/settings.py +++ b/makeabilitylab/settings.py @@ -86,8 +86,8 @@ SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # Makeability Lab Global Variables, including Makeability Lab version -ML_WEBSITE_VERSION = "2.16.1" # Keep this updated with each release and also change the short description below -ML_WEBSITE_VERSION_DESCRIPTION = "SEO: shorten the home page to 'HCI & AI Research at UW | Makeability Lab' so it stays under Google's ~60-character display limit (the 2.16.0 'University of Washington' variant was truncated). Follow-up to the 2.16.0 on-page SEO fixes." +ML_WEBSITE_VERSION = "2.16.2" # Keep this updated with each release and also change the short description below +ML_WEBSITE_VERSION_DESCRIPTION = "Analytics: load Google Analytics 4 (G-M18PCH55ZP) directly via the native gtag.js snippet instead of chain-loading it off the retired Universal Analytics analytics.js tag (a console-side 'connected site tag'). Removes the dead UA-79723676-1 snippet so GA4 collection no longer depends on deprecated UA machinery (#855)." DATE_MAKEABILITYLAB_FORMED = datetime.date(2012, 1, 1) # Date Makeability Lab was formed MAX_BANNERS = 7 # Maximum number of banners on a page diff --git a/website/templates/website/base.html b/website/templates/website/base.html index 9aae34b7..f5645fef 100644 --- a/website/templates/website/base.html +++ b/website/templates/website/base.html @@ -152,13 +152,15 @@ {% if debug %} <script>console.log("Development mode: Google Analytics disabled");</script> {% else %} + <!-- Google tag (gtag.js) — GA4 property G-M18PCH55ZP (#855). + Loads GA4 directly instead of chain-loading it off the retired Universal + Analytics analytics.js tag via a console-side "connected site tag". --> + <script async src="https://www.googletagmanager.com/gtag/js?id=G-M18PCH55ZP"></script> <script> - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) - })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); - ga('create', 'UA-79723676-1', 'auto'); - ga('send', 'pageview'); + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + gtag('config', 'G-M18PCH55ZP'); </script> {% endif %} </head>