Skip to content

fix(consent): load Ketch first and hold Heap and GA4 until consent - #143

Open
dg-coreylweathers wants to merge 1 commit into
mainfrom
fix/consent-ketch
Open

dg-coreylweathers wants to merge 1 commit into
mainfrom
fix/consent-ketch

Conversation

@dg-coreylweathers

Copy link
Copy Markdown
Contributor

What

cli.deepgram.com and cli.staging.deepgram.com load Heap and GA4 (G-TYPC1TBCKT) before any consent, including for visitors in GDPR regions and when Ketch is blocked, and have no Ketch and no privacy control. This brings the page in line with developers.deepgram.com:

  • web/src/consent/ketch.js: docs' fern/assets/ketch.js, copied verbatim (the Ketch loader for deepgram_marketing_site plus the dgOnConsent / dgOnRevoke helpers), inlined as the first script in <head>.
  • web/public/consent/dg-consent.js: docs' built consent banner, unchanged. It mounts the footer "Your Privacy Choices" control into <div id="fern-footer"> (the id the bundle looks for), and shows a Privacy Policy link instead when Ketch is unavailable. Source commit and hashes are in web/src/consent/SOURCE.json.
  • web/src/consent/trackers.js: Heap (docs' snippet, which also fixes the old heap[o]= stub bug) and GA4 start only after Ketch grants targeted_advertising, and stop if it's withdrawn (Heap stopTracking, GA ga-disable-<id>, then the banner's reload on withdrawal). Neither starts if Ketch never loads.
  • <html class="dark"> makes the banner use its dark theme to match the site. The page has no dark: utilities, so nothing else changes.

GA4 purpose: targeted_advertising. The live Ketch config (production/gdpr/en/config.json) lists _ga and _ga_*, along with Heap's _hp2_*, under targeted_advertising. Nothing related is listed under analytics.

Checked

Built with npm ci && npm run build (node:22, Docker), served dist/, then ran Playwright with a fresh profile each time and Ketch's location stubbed:

Before (live) After (local build)
Ketch first script in <head> no Ketch yes
GB, no choice Heap, GA4, doubleclick, _ga cookies nothing loads, no cookies, banner auto-opens: Reject All · Customize · Accept All
GB Reject All / Accept All n/a nothing loads / Heap and GA4 load
US-CA (opt-out state) everything no auto-open; Heap and GA4 load (granted by default, as on docs)
Ketch blocked everything nothing loads, footer shows Privacy Policy

Notes

  • Production deploys only from a GitHub release (web-production.yml), so merging this updates staging only. cli.deepgram.com keeps the ungated trackers until the next release.
  • deepgram/deepgram-docs#1302 plans to retire cli.deepgram.com. If the redirect ships first, this goes away with it.
  • To update these files, copy them again from the same docs commit. Don't edit them here.

Vendors developers.deepgram.com's ketch.js (Ketch loader plus the
dgOnConsent/dgOnRevoke helpers) as the first script in <head> and its
built consent banner, dg-consent.js, unchanged. Heap and GA4 now start
only after Ketch grants targeted_advertising, the purpose the Ketch
config lists their _hp2_* and _ga cookies under, and stay off when
Ketch never loads. The footer gets the Your Privacy Choices control,
or a Privacy Policy link when Ketch is unavailable.

This branch has not been deployed

No deployments
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.

1 participant