pnpm installpnpm devpnpm build
pnpm startpnpm biome:lint # lint and auto-fix
pnpm biome:format # format
pnpm biome:check # run all checksinfinidream.ai loads GA4 on every page via
src/components/Analytics/Analytics.tsx /
src/lib/analytics.ts
getVariant()reads thevariantcookie (see A/B test below) and is always sent as an event parameter, including on the automaticpage_view. With the A/B test off this is just"unknown"for everyone.trackSignUpClick(location)fires asign_up_clickevent ({ variant, location }) when a visitor clicks a "Start Free" / "Create an account" CTA.locationidentifies which CTA (e.g."hero","nav","content") so conversion can be broken down per button.- Sign-up itself completes on
alpha.infinidream.ai, a different app the landing page can't observe, so there's nosign_up(completion) event here, onlysign_up_click.
variant and location are already registered in GA4 as event-scoped custom
dimensions (Admin → Custom definitions), this is a one-time setup and is done. Nothing in
GA needs to change to start or stop an A/B test.
infinidream.ai can run a 50/50 A/B test between main (production) and any other deployed
branch, controlled entirely by one Cloudflare Pages environment variable,
VARIANT_B_ORIGIN.
- Set (Cloudflare dashboard → Workers & Pages →
landing-page→ Settings → Environment variables → Production → addVARIANT_B_ORIGIN= the challenger branch alias, e.g.https://old-design.landing-page-d44.pages.dev) → the test is live. - Delete that variable (or clear its value) → the test is off,
mainis served directly to everyone, no cookie gets set. This is the current/default state.
functions/_middleware.js is the Cloudflare Pages Function that
implements this, and it is always present in the repo (on or off is just whether the env var
is set):
- If
VARIANT_B_ORIGINisnt set, the Function immediately gets out of the way (return next()), production behaves exactly as if this file didnt exist. - Otherwise, it reads the
variantcookie from the request. - No cookie (first visit): rolls 50/50 → assigns
AorB, then setsSet-Cookie: variant=A|B(Path=/, 1-yearMax-Age,SameSite=Lax,Secure, notHttpOnly, the client needs to read it). variant=A→ served normally by this deployment.variant=B→ transparentlyfetch()es the same path fromVARIANT_B_ORIGINand returns that response. The browser URL staysinfinidream.aithroughout.- QA override: visiting with
?variant=Aor?variant=Bforces that variant and (re)pins the cookie, for manually testing each side.