feat(consent): gate host-side visitor recognition on cookieTracking consent - #75
Closed
0xgautam wants to merge 2 commits into
Closed
feat(consent): gate host-side visitor recognition on cookieTracking consent#750xgautam wants to merge 2 commits into
0xgautam wants to merge 2 commits into
Conversation
…onsent Adds `cookieTracking` as a third category of `SurfaceSetConsent`, mirroring the new Cookie Tracking privacy control in Forms (trysurface/surface_forms#5811). Every call is a complete snapshot, so an older two-field call denies cookies. Pages that load the tag with `data-consent-mode` get a tag that does no visitor recognition until that category is granted: no identify or fingerprint, no `surfaceLeadData` cache read/write, no journey cookies or page-view beacons, and an empty cookie snapshot in STORE_UPDATE. A grant starts all of it; withdrawal clears the journey cookies and lead cache. Frames still receive their handshake so forms render and submit as before. Without the attribute nothing changes for existing installs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
0xgautam
force-pushed
the
agent/cookie-consent-runtime
branch
from
September 6, 2026 20:28
aac8f18 to
0dea851
Compare
… document `SurfaceSetConsent` now also writes the normalized snapshot to `window.__SURFACE_CONSENT__` and dispatches a `surface:consent` DOM event, and the tag reads a snapshot an SDK that loaded first left there. This is how a customer-hosted SDK form and the tag agree on one banner answer without either wrapping the other's API. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Collaborator
Author
|
Superseded: the Surface Tag source now lives in the monorepo at packages/surface-scripts, so this change moved to a PR stacked on trysurface/surface_forms#5811 (branch agent/privacy-cookie-consent-tag). Nothing further will land here. |
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.
What does this PR do?
Adds
cookieTrackingas a third category ofSurfaceSetConsent, matching the new Cookie Tracking privacy control in trysurface/surface_forms#5811, and lets a page opt the tag into waiting for it.Pages that run a consent banner load the tag with
data-consent-mode:With the attribute, until
cookieTrackingis granted the tag:surfaceLeadDatacachesurface_journey_id/surface_recent_visitcookies and sends no page-view beaconssurfaceLeadData: nullanduserJourneyId: nullinSTORE_UPDATESEND_DATAhandshake withSTORE_UPDATEandLEAD_DATA_UPDATE, so the form renders, identifies without recognition and submits as beforeA grant starts journey tracking, identifies and pushes lead data to the frames. Withdrawal clears the journey cookies and the lead cache. Every
SurfaceSetConsentcall is a complete snapshot, so an older two-field call denies cookies.Every answer is also written to
window.__SURFACE_CONSENT__and dispatched as asurface:consentDOM event, and the tag reads a snapshot an SDK that loaded first left there. That is how a customer-hosted Forms SDK form and the tag agree on one banner answer without wrapping each other's API.Without the attribute nothing changes. Journey tracking on pages without forms, the public
SurfaceIdentifyLeadAPI, cookie forwarding, conversions, HTML forms and open triggers all behave exactly as onmain.Rollout
Deploy order does not matter. An old Forms build ignores the extra boolean; a new Forms build with the old tag gates itself inside the iframe. Rollback is a plain revert of this bundle.
Testing
pnpm typecheckpnpm test: 25 tests pass, including newSurfaceStorecases for consent mode (no journey, identify or cache read before a grant; grant starts them and forwards cookies; withdrawal clears them; no attribute means no change) and a listener case for the denied handshake.pnpm build,cmp surface_tag.js surface_embed_v1.jsgit diff --checktest/consent.htmlagainst a Forms staging deploy: pending.Testing Instructions
test/consent.htmlnow loads the tag withdata-consent-modeand has a Cookies checkbox. Serve the repo root, open it in tag mode against a form whose Cookie Tracking is On consent, and check in devtools: before answering there are nosurface_journey_id,surface_recent_visitorsurfaceLeadDataentries and nolead/identifyorlead/trackrequests; after accepting they appear; after withdrawing the cookies and cache are removed. Load any other test page without the attribute to confirm the old behavior.