Add HubSpot cookie banner and consent-gated Amplitude to docs#32
Open
Kaysahni wants to merge 1 commit into
Open
Add HubSpot cookie banner and consent-gated Amplitude to docs#32Kaysahni wants to merge 1 commit into
Kaysahni wants to merge 1 commit into
Conversation
Mirror the consent + analytics pattern from flox.dev on the Mintlify docs site. Adds two custom JS files that Mintlify auto-loads on every page: - hubspot.js: injects HubSpot tracking (portal 23414950, same as flox.dev) only on production hostnames. Portal config controls banner display. - amplitude.js: registers a HubSpot privacy-consent listener and loads Amplitude only after analytics consent is granted. Routes prod hostnames to the "Production - Flox" project and all other hostnames to the "Test Project" key, matching the floxwebsite and FloxHub split. PROD_HOSTS = flox.dev, www.flox.dev, flox.mintlify.dev. Any other origin (localhost, branch previews) loads no HubSpot script and therefore no Amplitude. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
stephenyeargin
approved these changes
Jun 29, 2026
| try { | ||
| if (typeof window === 'undefined') return; | ||
|
|
||
| var PROD_HOSTS = ['flox.dev', 'www.flox.dev', 'flox.mintlify.dev']; |
Member
There was a problem hiding this comment.
I recall there's a setting to add a domain to HubSpot for this to work, so it may be worth confirming.
Collaborator
Author
There was a problem hiding this comment.
Double checked. this is applicable if we go subdomain like docs.flox.dev apparently flox.dev/docs uses the same one as the main site.
Member
There was a problem hiding this comment.
Ah, I was referring to the *.mintlify.dev domain.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hubspot.jsandamplitude.jsat repo root. Mintlify auto-loads any.jsfile in the content directory on every page.hubspot.jsinjects the same HubSpot portal (23414950) used on flox.dev, but only on production hostnames. The cookie banner itself is rendered/configured by HubSpot portal settings (Privacy & Consent → Cookies), so updating banner copy or geo scope is done in HubSpot, not in code.amplitude.jsregisters a_hsp.addPrivacyConsentListenercallback and only loads Amplitude after analytics consent is granted. The init payload (autocapture flags, Session Replay sample rate) mirrorsfloxwebsite/src/lib/amplitude.tsxso docs analytics shape matches the website.flox.dev,www.flox.dev,flox.mintlify.dev) → "Production - Flox" Amplitude project (6f89e78c…). All other hostnames → "Test Project" (820bc93b…). Same split that floxwebsite and FloxHub use.Why gate HubSpot on hostname
floxwebsite/src/pages/_app.tsxonly renders the HubSpot script whenisProductionDeploymentis true. The Mintlify.jsfiles have no env-var system, so we replicate that gate by checkinglocation.hostname. Without this, every localhost page load on a non-EU IP would auto-load Amplitude with the prod key (HubSpot fires its consent listener withanalytics: trueby default on origins it doesn't manage).Test plan
npx mintlify devon localhost: confirm nojs.hs-scripts.comand nocdn.amplitude.comrequests;window.amplitudeis undefined.PROD_HOSTS).https://flox.dev/docs/from an EU/CA IP: HubSpot cookie banner appears (per HubSpot portal geo config). Decline → no Amplitude requests. Accept →cdn.amplitude.com/script/6f89e78c…jsloads, events POST toapi2.amplitude.com.https://flox.dev/docs/from a US IP: HubSpot fires consent listener withanalytics: true(matches website behavior), Amplitude loads against the prod project.PROD_HOSTS(flox.mintlify.dev) still matches what Mintlify actually serves. If Mintlify migrates to a different prod hostname, updatePROD_HOSTSin both files.🤖 Generated with Claude Code