From b53150434ed7f9e4c8ac7777b22e4abe156d9d32 Mon Sep 17 00:00:00 2001 From: Timur Mashara Date: Mon, 12 Oct 2026 12:23:56 +0200 Subject: [PATCH 1/2] Load VWO on every docs page and report cookie consent to it (GRO-1076) Co-Authored-By: Claude Opus 5.5 --- _includes/marketing-vwo.html | 27 +++++++++++++++++++++++++-- public/docs/js/cookie-consent.js | 16 +++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/_includes/marketing-vwo.html b/_includes/marketing-vwo.html index 58ece0d3d2..d5e711aa2d 100644 --- a/_includes/marketing-vwo.html +++ b/_includes/marketing-vwo.html @@ -1,4 +1,28 @@ -{% if page.vwo or include.force_enabled %} + -{% endif %} diff --git a/public/docs/js/cookie-consent.js b/public/docs/js/cookie-consent.js index 3e5c886c95..d7ed65dbc1 100644 --- a/public/docs/js/cookie-consent.js +++ b/public/docs/js/cookie-consent.js @@ -211,6 +211,12 @@ // analytics + // VWO consent states: 1 = accepted, 3 = rejected (2 = pending is the + // initial state set in `_includes/marketing-vwo.html`). + function setVwoConsent(accepted) { + window.VWO?.init?.(accepted ? 1 : 3); + } + let hasAnalyticsScripts = false; let haveConsent; function loadAnalyticsScripts(accepted) { @@ -260,6 +266,9 @@ (gdprcookie.analytics === undefined && !geolocation.hasCookiePolicyRestriction); loadAnalyticsScripts(accepted); + // A stored choice was already passed to VWO in `marketing-vwo.html`; this + // covers implied consent outside restricted countries. + if (accepted) setVwoConsent(true); } function checkBarDismissed() { @@ -332,9 +341,10 @@ loadMarketingScripts(); } - loadAnalyticsScripts( - typeof e.detail === "boolean" ? e.detail : e.detail.analytics, - ); + const analytics = + typeof e.detail === "boolean" ? e.detail : e.detail.analytics; + loadAnalyticsScripts(analytics); + setVwoConsent(analytics); document.body.classList.add("cookies-accepted"); hideBar(); From 856b776b5325c220f4b9dfd8ce7334d901945c46 Mon Sep 17 00:00:00 2001 From: Timur Mashara Date: Tue, 13 Oct 2026 11:42:31 +0200 Subject: [PATCH 2/2] change hideElement to empty for non-experiment pages / load vwo only for prod build --- _includes/marketing-vwo.html | 6 +++++- src/pages/docs/[version]/[...slug].astro | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/_includes/marketing-vwo.html b/_includes/marketing-vwo.html index d5e711aa2d..c69840cdee 100644 --- a/_includes/marketing-vwo.html +++ b/_includes/marketing-vwo.html @@ -1,3 +1,6 @@ +{% if jekyll.environment == "production" %} +{% assign vwo_experiment_paths = "" | split: "," %} +{% if vwo_experiment_paths contains page.url %}{% assign vwo_hide_element = "body" %}{% else %}{% assign vwo_hide_element = "" %}{% endif %} +{% endif %} diff --git a/src/pages/docs/[version]/[...slug].astro b/src/pages/docs/[version]/[...slug].astro index f87809bf30..cd61cd5f99 100644 --- a/src/pages/docs/[version]/[...slug].astro +++ b/src/pages/docs/[version]/[...slug].astro @@ -62,7 +62,12 @@ const page = { url, ...doc.data }; // Process liquid first (e.g. control flow, includes, variables, etc) const lq = getLiquidRenderer({ page, dirname }); -const lqOutput = await lq.render(doc.body!, undefined, { +// Standalone `.html` docs skip the shared head, so add VWO to their own ``. +const lqSource = + kind === "html" + ? doc.body!.replace("", "{% include marketing-vwo.html %}") + : doc.body!; +const lqOutput = await lq.render(lqSource, undefined, { maxSyntaxErrors: version === "latest" ? 0 : 3, });