Repository navigation
Add cookie consent banner and gate GTM and PostHog on consent - #7951
Open
adidavid014 wants to merge 3 commits into
Open
adidavid014 wants to merge 3 commits into
adidavid014 wants to merge 3 commits into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
adidavid014
requested review from
jkonrath-postman and
nerminamiller-postman
as code owners
November 20, 2026 20:16
Contributor
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Contributor
…state Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Devin Review found 2 findings. Devin automatically fixed all 2 findings.
Fixed by Devin (2)
- Analytics storage remains denied after consent — apply() now pushes a Consent Mode update (analytics_storage granted) when analytics is granted while GTM is already running.
- Consent rejection leaves analytics running — Revocation now compares against in-page state (
active), not the previous cookie, and the cookie is re-synced on focus, so blocked cookies or another tab's revoke still turn PostHog off and reload.
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
Adds a cookie banner to buildwithfern.com/learn with Accept all, Reject all and Manage. Manage shows Analytics and Marketing toggles. This is a stopgap with no vendor; we can swap in Transcend later.
fern/cookie-consent.jsloads withbeforeInteractive. It shares thefern_cookie_consent=analytics:1|marketing:0cookie on.buildwithfern.comwith the marketing site (fern-api/marketing-site#582).settings.require-analytics-consent: true. The script setswindow.fernAnalyticsConsentand dispatchesfern-analytics-consent.analytics.gtmbecause Fern doesn't gate that on consent.GTM-55W3VNDWafter consent, with a Consent Mode default that setsanalytics_storagefrom the Analytics choice.fern-docs-track-analyticsevents todataLayer, withoutemail.active), not the previous cookie. Revoking a category clears its cookies and reloads the page. The cookie is re-read on focus, so changes from another tab or from the marketing site apply too.data-fern-cookie-settings) reopens the banner with the toggles.Verified with
fern docs devin Chrome:fernAnalyticsConsentisfalse.fernAnalyticsConsenttotrueand loads no GTM.gtm.js.Not verified locally: Fern's built-in PostHog, which doesn't load in local preview.
Link to Devin session: https://app.devin.ai/sessions/a28af354dc5b4d36a8c96f5a9731b5a8
Open in Devin Desktop: https://app.devin.ai/desktop/session/a28af354dc5b4d36a8c96f5a9731b5a8?variant=devin
Requested by: @adidavid014
🟢 Devin fixed all 2 findings · Follow Devin's work