Add analytics: GA4 + Google Ads click-ID tracking - #133
Conversation
Add a Mintlify custom JS file (auto-included on every page) that reads gclid/gbraid/wbraid from the landing URL and persists them as photon_* cookies scoped to photon.codes for conversion attribution.
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe browser extracts ChangesClick ID tracking and GA4 configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Mergeability Score: ⚪ Minimal · up to The PR adds GA4 configuration and persists advertising click IDs for attribution; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant LandingURL
participant ClickIDScript
participant BrowserCookie
LandingURL->>ClickIDScript: Provide click ID parameters
ClickIDScript->>BrowserCookie: Store encoded IDs for 90 days
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Register measurement ID G-WDQR0KJG87 through docs.json's integrations.ga4 field rather than a raw gtag snippet, so page views are tracked correctly across Mintlify's client-side SPA navigation.
Update the ga4 integration measurement ID from G-WDQR0KJG87 to the new GT- Google tag. Mintlify's schema requires the ID start with 'G' (pattern ^G), which GT-TXXP8686 satisfies, and gtag.js loads GT- tags identically.
Adds two analytics/attribution pieces to the docs.
1. Google Analytics / Google tag —
docs.base.jsonRegisters Google tag ID
GT-TXXP8686via Mintlify's native GA4 integration (integrations.ga4.measurementId) rather than pasting the rawgtag.jssnippet. The native path tracks page views correctly across Mintlify's client-side SPA navigation — a raw snippet would only firepage_viewon the initial hard load. (Mintlify GA4 docs)Note on the
GT-prefix: this is a unified Google tag, not aG-GA4 measurement ID. Mintlify's docs.json schema requires the ID match^G(start withG), whichGT-TXXP8686satisfies, andgtag.jsloadsGT-tags with the identical?id=loader +gtag('config', ...)mechanism — so the native integration works.Config lives in
docs.base.json(the source of truth);docs.jsonis generated from it byscripts/build-navand is gitignored.2. Google Ads click-ID tracking —
click-id-tracking.jsA Mintlify custom JS file (auto-included on every page) that captures a Google Ads click identifier from the landing URL into
photon_*cookies scoped tophoton.codes, so conversions can be attributed after the visitor navigates within the site.gclid>wbraid>gbraid, capped at 512 chars — plus aphoton_ads_click_captured_attimestamp cookie.captured_atfor cookies set by the earlier version of this script.<head>— an unavoidable Mintlify constraint. Still readswindow.location.searchon the initial landing load, which is all click-ID capture needs.Domain=photon.codes(docs canonical ishttps://photon.codes/docs), sharing it across the apex domain.Behavior verified across 8 scenarios (first landing, reload, stale-type cleanup, new-click replacement, organic visit, migration, over-length id, encoding round-trip).