Skip to content

Gate Intercom and GTM on CookieYes consent - #138

Open
ejntaylor wants to merge 1 commit into
mainfrom
gate-intercom-gtm-on-cookieyes-consent
Open

ejntaylor wants to merge 1 commit into
mainfrom
gate-intercom-gtm-on-cookieyes-consent

Conversation

@ejntaylor

Copy link
Copy Markdown
Member

docs.patchstack.com now loads Intercom and Google Tag Manager only after CookieYes consent, the same way patchstack.com does. Before this change, GTM loaded before CookieYes and before any choice. Intercom used the stock snippet, so only CookieYes' widget.intercom.io/widget|intercom.io blocking rule kept it from loading before consent. That rule is about to be removed so chat can load on click on the website and Hub, so docs now gates Intercom itself.

Order in <head> (src/components/Head.astro)

  1. Google Consent Mode defaults (everything denied except security) and ads_data_redaction. Previously this was a processed <script> that Astro bundled as a deferred module, so it actually ran after GTM.
  2. CookieYes script.js, loaded synchronously and first, as on the website.
  3. GTM starts once Analytics or Advertisement is accepted. This is the website's GTMScript.astro unchanged. Tags inside container v62 check Consent Mode and trigger on cookie_consent_update.
  4. Intercom loads once Functional is accepted.

GTM and Intercom both listen for cookieyes_banner_load (stored consent, every page load) and cookieyes_consent_update (a choice made on this page), so consent given later on the same page also loads them.

Chat links: before consent, the #launch-intercom links on FAQ pages open the CookieYes preferences instead of calling Intercom("show"), which would throw. Once the visitor allows Functional there, chat opens.

Also removed: the GTM <noscript> iframe, since a visitor without JavaScript can't consent, and url_passthrough. The website removed both in its consent PR.

Testing

  • Setup:
    • The built site was served locally over HTTPS and mapped to docs.patchstack.com in Chrome, so the real CookieYes banner (activeLaw: gdpr) loaded.
    • The browser used a Tor exit in the Netherlands (directory.cookieyes.com/api/v1/ip → in_eu: true).
    • Every third-party request was logged before the choice, after the choice on the same page, and after a reload.
  • "Rule removed" run: the same suite was run again with CookieYes script.js served with the widget.intercom.io/widget|intercom.io rule stripped from _providersToBlock.

Results were the same with and without the rule:

Choice Loaded
No choice nothing
Reject All nothing, including after reload
Functional Intercom only
Analytics GTM, gtag.js, Hotjar
Advertisement GTM, Google Ads (ccm), LinkedIn, Facebook
Accept All everything above
Chat link → allow Functional Intercom loads and the messenger opens

On main, gtm.js loads before any choice. With the rule stripped, main also loads Intercom before any choice and after Reject All.

For the GTM owner: Analytics-only consent sends no GA4 collect hit on main or on this branch. Only the gtag.js library loads, and GA4 hits appear only once Advertisement is also granted. This comes from the container or GA4 setup, not from this change.

Load the Consent Mode defaults and CookieYes first, then start GTM only
after Analytics or Advertisement consent and Intercom only after
Functional consent, matching patchstack.com. Both listen for CookieYes'
cookieyes_banner_load and cookieyes_consent_update events, so consent
given later on the same page also loads them, and docs no longer relies
on CookieYes' Intercom script-blocking rule.

Before consent, #launch-intercom links open the CookieYes preferences
instead of calling the missing Intercom, and open chat once the visitor
allows it there. Drop the GTM noscript iframe and url_passthrough, which
only acted without consent.

Co-authored-by: Elliot Taylor <elliot.t@patchstack.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1f036-4d30-7305-867a-24f414b75cc8
@coderbuds

coderbuds Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

🎯 Elite quality (92%) — Properly gates GTM and Intercom behind CookieYes consent events, with clear ordering and explanatory comments.

📦 Medium

🤖 Written by Amp — going by its own attribution. Unknown whether a person read it; agents can report that with the report-ai-usage tool.

🔴 Risk: Minimal · Low · Elevated · High — returns silently when window.revisitCkyConsent is missing, leaving chat links dead with no feedback in src/components/Head.astro, so a failure there would go unnoticed.

✅ Reviewed — approved by @daniloradovic.

See how your team is trending →

@netlify

netlify Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for deluxe-meerkat-8daf24 ready!

Name Link
🔨 Latest commit d2086be
🔍 Latest deploy log https://app.netlify.com/projects/deluxe-meerkat-8daf24/deploys/6afe082f5daf6984374224e2
😎 Deploy Preview https://deploy-preview-138--deluxe-meerkat-8daf24.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ejntaylor

Copy link
Copy Markdown
Member Author

/review

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.

3 participants