Skip to content
This repository was archived by the owner on Oct 14, 2026. It is now read-only.

Load VWO on every docs page and report cookie consent to it (GRO-1076) - #1379

Closed
tmashara wants to merge 2 commits into
masterfrom
gro-1076-track-vwo-experiment-attribution-across-the-website
Closed

tmashara wants to merge 2 commits into
masterfrom
gro-1076-track-vwo-experiment-attribution-across-the-website

Conversation

@tmashara

@tmashara tmashara commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Docs counterpart of metabase/metabase.github.io#6645, same change. Closes GRO-1076. Decision and trade-offs: VWO vs mb_track (we chose approach A).

  • VWO now loads on every docs page (it used to need vwo: true, which no page set), so docs visits can be VWO goals.
  • We tell VWO the visitor's analytics consent (VWO.init(1 | 2 | 3)) so its "Partially Block" mode can hold tracking until consent.

Important

Ship together with metabase/metabase.github.io#6645. Right after both are deployed, switch on Enable Cookie Consent → Other → Partially Block in the VWO account. Until it's on, VWO ignores consent and tracks every visitor.

How to verify

  1. Start the docs dev server: bunx astro dev.
  2. In a private window, open http://localhost:4321/docs/latest/. Without seeded docs it renders the 404 page, which uses the same <head>, so that's fine for this check.
  3. DevTools → Network, filter visualwebsiteoptimizer, type All, tick Disable cache: j.php and collect/v.gif show that VWO is loaded.
  4. Console, window.VWO.consentState: 1 outside restricted countries, or 2 (pending) if you're in one.
  5. Simulate an EU visitor: DevTools → Network request blocking → block get.geojs.io (a failed geo lookup is treated as restricted). Clear site data and reload: consentState is 2.
  6. Click Accept cookies: consentState becomes 1.
  7. Clear site data and reload, then Settings → uncheck Analytics → Save settings: consentState becomes 3.
  8. Reload: consentState is 3 right away, because the stored choice is passed to VWO before the snippet runs.

@linear

linear Bot commented Oct 12, 2026

Copy link
Copy Markdown

GRO-1076

@github-actions

github-actions Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

The deployments were removed when this pull request closed. Reopening it deploys again at the same address.

@tmashara
tmashara marked this pull request as ready for review October 12, 2026 10:30
@tmashara
tmashara requested a review from a team October 12, 2026 10:31
@losrebellos
losrebellos requested a lite review from Copilot October 12, 2026 16:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Standalone HTML docs still bypass VWO, and site-wide body hiding can temporarily blank pages when VWO is slow.

2 open findings
What changed in this PR

This PR aims to make docs visits available as VWO goals and pass analytics consent to VWO.

Changes:

  • Loads the VWO snippet without the previous page-level condition.
  • Initializes VWO from stored consent and updates it when a visitor makes a choice.
File Description
public/​docs/​js/​cookie-consent.js Sends analytics consent changes to VWO.
_includes/​marketing-vwo.html Loads VWO and sets its initial consent state.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@@ -1,4 +1,28 @@
{% if page.vwo or include.force_enabled %}
<script type="text/javascript" id="vwoConsent">

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scoped this to experiments pages paths only (empty for the docs repo)

@@ -1,4 +1,28 @@
{% if page.vwo or include.force_enabled %}
<script type="text/javascript" id="vwoConsent">

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, injected the vwo script into those pages

iethree
iethree previously approved these changes Oct 12, 2026

@losrebellos losrebellos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Agree with Copilot regarding hide_element='body', it should be "" or a narrow selector
  • VWO should be available on production only, like other tracking, etc. libs we're using. WDYT?

@iethree

iethree commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Is there a way we can get vwo tracking behavior on every page while keeping the render-delaying behavior only on pages we're a/b testing?

@iethree
iethree dismissed their stale review October 12, 2026 23:03

Ben is right!

@tmashara
tmashara force-pushed the gro-1076-track-vwo-experiment-attribution-across-the-website branch from efd5aff to 856b776 Compare October 13, 2026 09:58
@tmashara

Copy link
Copy Markdown
Contributor Author

Is there a way we can get vwo tracking behavior on every page while keeping the render-delaying behavior only on pages we're a/b testing?

yes, by keeping a hardcoded list of experiment page paths and only enabling hide_element on those pages. A bit fragile since we’d need to keep the list up to date, but I think it’s worth it

Agree with Copilot regarding hide_element='body', it should be "" or a narrow selector

updated, now we have only for the tested pages (no such pages in the docs repo btw)

VWO should be available on production only, like other tracking, etc. libs we're using. WDYT?

agree, updated

@tmashara
tmashara requested a review from losrebellos October 13, 2026 11:05
@tmashara tmashara closed this Oct 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants