A/B Landing Copy Lab
AI generates two headlines, sticky cookie buckets assign A/B, and Redis/memory tracks impressions and conversions.
Run this experiment yourself
Demos are not embedded on this site. Deploy a standalone copy on Vercel or run the experiment app locally.
Local development
cd apps/experiments/ab-landing-copy-lab pnpm install pnpm dev
Then open http://localhost:3010.
This is an experimental demo. Use it as a starting point for your own projects.
A/B Landing Copy Lab uses generateObject to create two headlines, assigns visitors to sticky cookie buckets (Set-Cookie), and records impression/conversion counters in Redis or memory. Missing AI keys return 503.
Features
- Two headlines – A/B variants from a product topic.
- Sticky cookie bucket –
ab_landing_bucketviaSet-Cookie. - Funnel counters – impressions + conversions with rates.
- Honest
503when AI is not configured.
Server Reference
POST /api/generate
{ "topic": "..." }GET /api/assign
Returns { bucket, headline } and sets cookie when new.
POST /api/event
{ "bucket": "A", "type": "impression" }GET /api/stats
Funnel totals + conversion rates.
| Status | Cause |
|---|---|
503 | No AI provider (generate) |
400 | Invalid event payload |
Implementation Details
Generate
generateObject for headlines A and B.
Assign + measure
Cookie sticky bucket; Redis/memory counters.
Use Cases
- Learn AI + cookie cohort composition.
- Prototype landing copy experiments.
Limitations
- Demo-scale counters; not a stats platform.
- No significance testing.
Use in your project
Copy handlers from apps/experiments/ab-landing-copy-lab/.
Deployment
Local Development
cd apps/experiments/ab-landing-copy-lab
pnpm install
pnpm devConfiguration
| Variable | Required | Purpose |
|---|---|---|
AI_GATEWAY_API_KEY | Yes (or OPENAI_API_KEY) | Headline generation |
UPSTASH_REDIS_REST_URL / TOKEN | No | Durable funnel stats |
Vercel / Next.js Features Used
- AI SDK
generateObject - Cookies /
Set-Cookie - Upstash Redis
- Route Handlers