Skip to content

Add google analytics to download page#1240

Open
keithah wants to merge 1 commit intomainfrom
keithah-google-analytics
Open

Add google analytics to download page#1240
keithah wants to merge 1 commit intomainfrom
keithah-google-analytics

Conversation

@keithah
Copy link
Copy Markdown
Member

@keithah keithah commented Apr 16, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 16, 2026 16:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Google Analytics (gtag.js) tracking to the per-distribution download page.

Changes:

  • Injects the Google tag loader script for measurement ID G-E3BVDYNVRP
  • Adds an inline GA initialization/config snippet on the download page

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

Comment on lines +34 to +36
<!-- Google tag (gtag.js) -->
<script
async src="https://www.googletagmanager.com/gtag/js?id=G-E3BVDYNVRP"></script>
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

These <script> tags are rendered before <BaseLayout>, but BaseLayout.astro outputs the document <!doctype html><html><head>... (src/layouts/BaseLayout.astro:35+). That means this page will emit scripts before the doctype/html element, producing invalid document structure (and potentially quirks mode / scripts not where expected). Move the GA (and the existing AdSense) tags into the layout <head> (e.g., add a named head slot in BaseLayout and pass them via the page) so they render inside <head>.

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +42
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-E3BVDYNVRP');
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

In Astro, an inline <script> in a .astro template is processed/bundled as a module unless marked is:inline. In module scope, dataLayer is not a global binding, so dataLayer.push(...) will throw a ReferenceError when gtag() runs. Fix by making this script is:inline (classic script semantics) and/or by referencing window.dataLayer explicitly (e.g., assign a local const dataLayer = window.dataLayer = window.dataLayer || []) and attaching gtag to window if it needs to be globally callable.

Suggested change
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-E3BVDYNVRP');
<script is:inline>
const dataLayer = window.dataLayer = window.dataLayer || [];
window.gtag = window.gtag || function gtag(){dataLayer.push(arguments);}
window.gtag('js', new Date());
window.gtag('config', 'G-E3BVDYNVRP');

Copilot uses AI. Check for mistakes.
Comment on lines +35 to +42
<script
async src="https://www.googletagmanager.com/gtag/js?id=G-E3BVDYNVRP"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-E3BVDYNVRP');
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

The GA measurement ID is hard-coded here. To make it easier to change per-environment (staging/prod) and keep tracking IDs centralized, consider reading it from config/env (similar to how src/config/site.ts uses import.meta.env.PUBLIC_*) and only rendering the tag when the ID is set.

Copilot uses AI. Check for mistakes.
@kodiai
Copy link
Copy Markdown

kodiai bot commented Apr 16, 2026

Partial review -- timed out after analyzing 0 of 1 files (339s).

Retry skipped -- this repo has timed out frequently for this author.
Consider splitting large PRs to stay within the review timeout budget.

Review timed out before producing output. Retry skipped due to frequent timeouts for this repo/author.

@kodiai
Copy link
Copy Markdown

kodiai bot commented Apr 16, 2026

Review Details
  • Files reviewed: 1

  • Lines changed: +11 -0

  • Profile: strict (auto, lines changed: 11)

  • Contributor experience: profile-backed (using linked contributor profile guidance)

  • Findings: 0 critical, 0 major, 0 medium, 0 minor

  • Review completed: 2026-04-16T16:15:25.776Z

  • Total wall-clock: 12m 25s

  • Phase timings:

    • queue wait: 0ms
    • workspace preparation: 40s
    • retrieval/context assembly: 2.3s
    • executor handoff: 5m 59s
    • remote runtime: 5m 39s (degraded: remote runtime timed out)
    • publication: 2.0s (degraded: captured before publication completed)
  • Keyword parsing: No keywords detected

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