From d2086be3b511888d35701b33b2bb5add97d14353 Mon Sep 17 00:00:00 2001 From: Amp Date: Wed, 18 Nov 2026 20:00:08 +0000 Subject: [PATCH] Gate Intercom and GTM on CookieYes consent 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 Amp-Thread-ID: https://ampcode.com/threads/T-01a1f036-4d30-7305-867a-24f414b75cc8 --- src/components/Head.astro | 172 +++++++++++++++++++++++++--------- src/components/SkipLink.astro | 4 - 2 files changed, 130 insertions(+), 46 deletions(-) diff --git a/src/components/Head.astro b/src/components/Head.astro index 07f466e..88fac47 100644 --- a/src/components/Head.astro +++ b/src/components/Head.astro @@ -14,46 +14,74 @@ const canonicalImageSrc = new URL(imageSrc, Astro.site); - - - - - - - - - - - - + + + + @@ -77,14 +105,74 @@ window.addEventListener("load", function(){ }); + + (function () { + var loaded = false; + var chatRequested = false; + + function loadIntercom(isAccepted) { + if (loaded || !isAccepted('functional')) return; + loaded = true; + + window.intercomSettings = { + api_base: 'https://api-iam.intercom.io', + app_id: 'yyljw8tl' + }; + + var w = window; + var ic = w.Intercom; + if (typeof ic === 'function') { + ic('reattach_activator'); + ic('update', w.intercomSettings); + } else { + var d = document; + var i = function () { + i.c(arguments); + }; + i.q = []; + i.c = function (args) { + i.q.push(args); + }; + w.Intercom = i; + var s = d.createElement('script'); + s.type = 'text/javascript'; + s.async = true; + s.src = 'https://widget.intercom.io/widget/yyljw8tl'; + var x = d.getElementsByTagName('script')[0]; + x.parentNode.insertBefore(s, x); + } + // The visitor allowed chat from a chat link, so open it. + if (chatRequested) w.Intercom('show'); + } - diff --git a/src/components/SkipLink.astro b/src/components/SkipLink.astro index 1af7f67..220ba9d 100644 --- a/src/components/SkipLink.astro +++ b/src/components/SkipLink.astro @@ -3,10 +3,6 @@ import type { Props } from '@astrojs/starlight/props'; const PAGE_TITLE_ID = '_top'; --- - - - {Astro.locals.t('skipLink.label')}