chore(website): track plugin download clicks in Google Analytics (#685)#686
Conversation
Add a reusable DownloadLink.astro component that fires a GA4 `file_download` event when a download or store link on /downloads/ is clicked, so install activity can be analysed by platform, install method, and app version. Each event carries: - platform: stream-deck | mirabox (ready for ulanzi), reusing the ecosystem ids already used by the changelog version-check flow - method: direct (our download redirect) or store (Elgato Marketplace / Mirabox Space) - app_version: PUBLIC_IRACEDECK_VERSION at build time (omitted when blank) A single Astro-deduped bundled script wires every link from its data- attributes; the handler no-ops if gtag is unavailable and never blocks the navigation/download (GA4 flushes via sendBeacon). Internal instrumentation, invisible to users, so no changelog entry.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds a new ChangesGA4 Download Click Tracking
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Comment |
Related Issue
Fixes #685
What changed?
Adds GA4 event tracking to the download links on
/downloads/so install activity can be analysed by platform, install method, and the app version current at the time. GA4 is already loaded site-wide (G-HKB3F7KB00); previously no custom events were fired.packages/website/src/components/DownloadLink.astro— renders the anchor and, via a single Astro-deduped bundled<script>, attaches a click handler to everya[data-download-link]that firesgtag("event", "file_download", { platform, method, app_version }). Mirrors the existingChangelogLeadIn.astropattern (no inline<script>in MDX).downloads.mdxnow uses the component for all four links: the two direct-download buttons (method="direct") and the two store links (method="store"), taggedplatform="stream-deck"/"mirabox".Event parameters:
platformstream-deck,mirabox(ready forulanzi) — reuses the ecosystem ids from the changelog version-check flowmethoddirect(our download redirect) orstore(Elgato Marketplace / Mirabox Space)app_versionPUBLIC_IRACEDECK_VERSIONat build time; omitted when blankThe handler no-ops if
gtagis unavailable and never blocks the navigation/download — GA4 flushes the event viasendBeacon. Forward-compatible: when Ulanzi joins the downloads page it is instrumented identically withplatform="ulanzi", no new event name.Follow-up outside the repo:
platform,method, andapp_versionmust be registered as custom dimensions in the GA4 property to be queryable in reports.No changelog entry — internal instrumentation, invisible to users (per the changelog rule).
How to test
cd packages/website && pnpm devhttp://localhost:4321/downloads/.collect. Clicking any of the four links fires a request withen=file_downloadandep.platform/ep.method/ep.app_version(GA4 DebugView shows the same). Dev uses the fallback version1.22.0-dev.0.Verified locally:
pnpm --filter @iracedeck/website buildpasses and the built/downloads/index.htmlcarries the data attributes + inlined tracking script;pnpm lint,pnpm format, and the fullpnpm testsuite (177 files / 5401 tests) are green.Checklist
.astrocomponent with no testable TS logic (same as the existingChangelogLeadIn.astro). Verified via build + built-output inspection instead.Summary by CodeRabbit