From 06c5620d06d8936515ccfc8cf675e8fe732e8776 Mon Sep 17 00:00:00 2001 From: Jacob Tomlinson Date: Thu, 19 Nov 2026 15:12:37 +0000 Subject: [PATCH 1/2] Restore the original Tag Manager container on GitHub Pages Co-authored-by: Jacob Tomlinson's Agent <307618193+jacobtomlinson-bot@users.noreply.github.com> --- .github/workflows/pages.yml | 4 ++ src/layouts/Site.astro | 34 ++++++++++ src/pages/404.astro | 2 +- tests/analytics.spec.mjs | 130 ++++++++++++++++++++++++++++++++++++ 4 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 tests/analytics.spec.mjs diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 2c5da26..becdcdc 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -31,6 +31,10 @@ jobs: - run: npm ci - run: npx playwright install --with-deps chromium - run: npm run check + - name: Build production artifact with Tag Manager + run: npm run build + env: + DASK_PAGES_ANALYTICS: '1' - uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4 with: path: dist diff --git a/src/layouts/Site.astro b/src/layouts/Site.astro index b4e4ec3..9460ee3 100644 --- a/src/layouts/Site.astro +++ b/src/layouts/Site.astro @@ -6,15 +6,38 @@ import Header from '../components/Header.astro'; import Footer from '../components/Footer.astro'; import Dialogs from '../components/Dialogs.astro'; const { + analytics = true, title = 'Dask | Parallel Python', description = 'Dask is a flexible library for parallel computing in Python.', } = Astro.props; +const tagManagerId = 'GTM-P4GQM59'; +const enableTagManager = + analytics && + import.meta.env.PROD && + process.env.DASK_PAGES_ANALYTICS === '1' && + !process.env.READTHEDOCS_CANONICAL_URL && + Astro.site?.origin === 'https://dask.org' && + import.meta.env.BASE_URL === '/'; --- + {enableTagManager && } {title} @@ -26,6 +49,17 @@ const { + {enableTagManager && ( +