# A/B testing infrastructure or feature flags are set up

- **Pattern:** `ab-001761` (`marketing-conversion.conversion-infrastructure.ab-testing-setup`)
- **Severity:** low
- **Lifecycle:** active
- **Last modified:** 2026-04-18
- **Canonical URL:** https://auditbuffet.com/patterns/ab-001761
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-001761)

## Why it matters

Conversion improvements compound over time only when they can be measured, and a codebase with hardcoded CTA copy, button colors, and form layouts has no way to isolate what actually moves the needle. Feature flags and A/B testing infrastructure let you ship variant hero copy, alternate pricing layouts, or different signup flows to subsets of traffic and read the results — without that scaffolding, every change is a guess and positive outcomes cannot be attributed to any specific decision.

## Severity rationale

Low because absent experimentation infrastructure blocks iterative conversion improvements without breaking the current funnel.

## Remediation

Introduce at least one feature flag mechanism so conversion elements can be varied and measured. The simplest option is environment-variable-based flags in `src/lib/flags.ts`; the more robust option is PostHog feature flags, which ship with analytics already:

```tsx
const showNewHero = process.env.NEXT_PUBLIC_NEW_HERO === 'true'

// Or with PostHog
const enabled = useFeatureFlagEnabled('new-cta-copy')
```

Wrap variant-ready elements (hero copy, CTA color, pricing layout) in flag checks.

## Detection

- **ID:** `ab-testing-setup`
- **Severity:** `low`
- **What to look for:** Check `package.json` and codebase for A/B testing or feature flag tooling: (1) A/B testing libraries — `@vercel/edge-config`, `growthbook`, `statsig-js`, `launchdarkly-js-client-sdk`, `split.js`, `optimizely-sdk`; (2) Feature flag patterns — environment variable-based flags (checking `process.env.NEXT_PUBLIC_FEATURE_X`) used on conversion elements; (3) Google Optimize or similar script tags in the root layout; (4) PostHog or Amplitude feature flags (posthog.isFeatureEnabled(), amplitude.getVariant()).
- **Pass criteria:** List all A/B testing or feature flag mechanisms found in the codebase. At least 1 A/B testing library, feature flag system, or feature flag pattern is present that could be used to test conversion elements. Report even on pass: "X A/B testing or feature flag mechanisms found."
- **Fail criteria:** No A/B testing library, feature flag library, or feature flag pattern found. Every conversion element is hardcoded with no mechanism for testing variants.
- **Skip (N/A) when:** Project is pre-launch with fewer than 500 estimated monthly visitors. Signal: project_size is `small` and no analytics showing traffic data is configured. A/B testing requires traffic volume to be meaningful.
- **Detail on fail:** `"No A/B testing or feature flag infrastructure found. All CTA copy, colors, and form layouts are hardcoded with no variant-testing capability."`.
- **Remediation:** You cannot improve what you cannot test. A/B testing infrastructure is investment that pays off as traffic grows. The simplest approach is environment variable-based feature flags:

  ```tsx
  // Simple env-based flag
  const showNewHero = process.env.NEXT_PUBLIC_NEW_HERO === 'true'

  // Or with PostHog feature flags (if already installed)
  const { isFeatureEnabled } = useFeatureFlagEnabled('new-cta-copy')
  ```

  For a more robust setup, PostHog (which may already be in your stack for analytics) includes feature flags and experimentation at no additional cost.

Taxons: user-experience

HTML version: https://auditbuffet.com/patterns/ab-001761
