From ac8c03e4356305432c29ec754902efed7be0840b Mon Sep 17 00:00:00 2001 From: johnjeremiah Date: Fri, 29 May 2026 12:40:08 -0400 Subject: [PATCH 1/3] Fix GA4 consent mode to grant analytics immediately for non-EU/UK visitors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the GA4 consent defaults denied analytics_storage for all visitors globally and set wait_for_update: 2000, meaning GA4 would wait up to 2 seconds for CookieYes to resolve geolocation before firing. For visitors on slower connections (mobile, slower CPUs) CookieYes often didn't respond in time, causing GA4 to drop the session entirely and record no pageview. Since ~95% of fleetdm.com's audience is outside the EU/UK and never sees the CookieYes consent banner, this wait was unnecessary for the vast majority of visitors. Replaces the single global consent default with two region-scoped calls: - All visitors: analytics_storage granted immediately (no wait_for_update) - EU/EEA/UK/Switzerland only: analytics_storage denied, wait_for_update: 2000 This matches how CookieYes Advanced Consent Mode is intended to work — the consent banner and its associated wait only apply where legally required (GDPR/UK GDPR). Also fixes the internal referrer check in the Salesforce attribution helper, which was using strict equality against 'https://fleetdm.com/' and missing any visitor whose last internal page was /pricing, /blog, etc. Changed to startsWith so any fleetdm.com referrer is correctly classified as direct traffic. --- .../update-or-create-contact-and-account.js | 4 ++-- website/views/layouts/layout.ejs | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/website/api/helpers/salesforce/update-or-create-contact-and-account.js b/website/api/helpers/salesforce/update-or-create-contact-and-account.js index bbfe9f7f174..f0e18f93eb8 100644 --- a/website/api/helpers/salesforce/update-or-create-contact-and-account.js +++ b/website/api/helpers/salesforce/update-or-create-contact-and-account.js @@ -278,8 +278,8 @@ module.exports = { // If no medium was provided via utm parameter, set the source channel to "Organic". attributionDetails.sourceChannel = 'Organic'; - if(!marketingAttributionCookie.referrer || marketingAttributionCookie.referrer === 'https://fleetdm.com/') { - // If no referrer is set, or the referrer is set to the Fleet website, we'll assume this user came to the website directly + if(!marketingAttributionCookie.referrer || marketingAttributionCookie.referrer.startsWith('https://fleetdm.com')) { + // If no referrer is set, or the referrer is any fleetdm.com page, we'll assume this user came to the website directly attributionDetails.sourceChannelDetails = 'Direct traffic (DT)'; attributionDetails.campaign = 'Default-DT-Direct'; } else { diff --git a/website/views/layouts/layout.ejs b/website/views/layouts/layout.ejs index 080457066cc..5413d04ae08 100644 --- a/website/views/layouts/layout.ejs +++ b/website/views/layouts/layout.ejs @@ -40,15 +40,27 @@ function gtag() { dataLayer.push(arguments); } + // Non-EU/UK visitors: grant analytics immediately (no consent banner shown) gtag("consent", "default", { ad_storage: "denied", - ad_user_data: "denied", + ad_user_data: "denied", + ad_personalization: "denied", + analytics_storage: "granted", + functionality_storage: "granted", + personalization_storage: "denied", + security_storage: "granted", + }); + // EU/EEA/UK/Switzerland: deny everything, wait for CookieYes banner + gtag("consent", "default", { + ad_storage: "denied", + ad_user_data: "denied", ad_personalization: "denied", analytics_storage: "denied", functionality_storage: "denied", personalization_storage: "denied", security_storage: "granted", wait_for_update: 2000, + region: ["AT","BE","BG","HR","CY","CZ","DK","EE","FI","FR","DE","GR","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","RO","SK","SI","ES","SE","IS","LI","NO","GB","CH"], }); gtag("set", "ads_data_redaction", true); From 59abb4e658c412622e9361429cef40d0a71adad6 Mon Sep 17 00:00:00 2001 From: johnjeremiah Date: Fri, 29 May 2026 12:56:22 -0400 Subject: [PATCH 2/3] fixing the attribution code --- .../update-or-create-contact-and-account.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/website/api/helpers/salesforce/update-or-create-contact-and-account.js b/website/api/helpers/salesforce/update-or-create-contact-and-account.js index f0e18f93eb8..b451412bc7f 100644 --- a/website/api/helpers/salesforce/update-or-create-contact-and-account.js +++ b/website/api/helpers/salesforce/update-or-create-contact-and-account.js @@ -278,7 +278,17 @@ module.exports = { // If no medium was provided via utm parameter, set the source channel to "Organic". attributionDetails.sourceChannel = 'Organic'; - if(!marketingAttributionCookie.referrer || marketingAttributionCookie.referrer.startsWith('https://fleetdm.com')) { + let isFleetReferrer = false; + if(marketingAttributionCookie.referrer) { + try { + let parsedReferrerUrl = new URL(marketingAttributionCookie.referrer); + let referrerHost = parsedReferrerUrl.hostname.toLowerCase(); + isFleetReferrer = (referrerHost === 'fleetdm.com' || referrerHost.endsWith('.fleetdm.com')); + } catch (err) { + isFleetReferrer = false; + } + } + if(!marketingAttributionCookie.referrer || isFleetReferrer) { // If no referrer is set, or the referrer is any fleetdm.com page, we'll assume this user came to the website directly attributionDetails.sourceChannelDetails = 'Direct traffic (DT)'; attributionDetails.campaign = 'Default-DT-Direct'; From 92d56561f2b6e964bbc066e8606ae4a119eec0b0 Mon Sep 17 00:00:00 2001 From: johnjeremiah Date: Fri, 29 May 2026 13:41:32 -0400 Subject: [PATCH 3/3] fixing lint err --- .../helpers/salesforce/update-or-create-contact-and-account.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/api/helpers/salesforce/update-or-create-contact-and-account.js b/website/api/helpers/salesforce/update-or-create-contact-and-account.js index b451412bc7f..7843678502f 100644 --- a/website/api/helpers/salesforce/update-or-create-contact-and-account.js +++ b/website/api/helpers/salesforce/update-or-create-contact-and-account.js @@ -284,7 +284,7 @@ module.exports = { let parsedReferrerUrl = new URL(marketingAttributionCookie.referrer); let referrerHost = parsedReferrerUrl.hostname.toLowerCase(); isFleetReferrer = (referrerHost === 'fleetdm.com' || referrerHost.endsWith('.fleetdm.com')); - } catch (err) { + } catch (unused) { isFleetReferrer = false; } }