A/B Testing
A/B testing plugin that creates page variants in Payload collections and routes traffic at the edge via Next.js middleware.
Installation
pnpm add @focus-reactive/payload-plugin-ab About
The plugin adds A/B (split) testing to Payload CMS v3 projects running on Next.js. Editors create page variants directly inside the same collection as the original page, set a traffic percentage for each, and the plugin handles the rest. No separate variants collection or manual wiring is needed. On every save or delete, injected `beforeChange`, `afterChange`, and `afterDelete` hooks recompute a variant manifest (a path-keyed JSON object) and write it to a pluggable storage adapter. Two adapters ship with the package: `payloadGlobalAdapter` stores the manifest in a Payload global, while `vercelEdgeAdapter` writes it to Vercel Edge Config for sub-millisecond reads. Next.js middleware then reads the manifest at the edge and rewrites the incoming request to the assigned variant before any rendering happens, with no database round-trip. Variant documents are distinguished by an injected `_abVariantOf` relationship field. The plugin hides variants from the collection list view, makes the slug and tenant fields read-only on variants, and validates that the sum of variant pass percentages cannot exceed 100 (leaving the original at least 1%). Traffic percentages are versioned with the draft and publish lifecycle, so editing a percentage in the sidebar Variants panel stages it without affecting live traffic until the original page is published. Locale-aware manifest entries are generated automatically when Payload localization is enabled, and an optional `tenantField` supports multi-tenant setups. For measurement, an `ExperimentTracker` React client component reads the bucket and visitor cookies set by the middleware and pushes them to Google Analytics via `gtag` as custom dimension parameters. A `POST /api/_ab/duplicate` endpoint clones an existing page into a new variant with a hashed slug such as `about--4ji9`.
Package info
- Package name
@focus-reactive/payload-plugin-ab- Latest version
2.10.1- Unpacked size
- 181 kB
- License
- MIT
- Weekly downloads
- 322
- Last publish
- Oct 6, 2026
More from focusreactive
View profileTranslator
Translates localized Payload CMS content into any locale via pluggable providers, with document, bulk-collection, and per-field controls in the admin UI.
Collaborative Comments
Adds document-level and field-level comments to the Payload admin panel, with @mentions, email notifications, resolution, multi-tenancy and locale filtering.
Create Ideal CMS
Interactive CLI that scaffolds a production-ready Payload CMS monorepo preconfigured with FocusReactive plugins.
Presets
Save and apply reusable block configurations as presets in the Payload admin panel.
Analytics
Adds a GA4-backed analytics dashboard inside the Payload admin, with KPIs, sessions, and lead-action tracking driven by the GA4 Data API and gtag.js.
SEO
Adds live Yoast SEO analysis to the Payload v3 document editor with a SERP preview, keyphrase checks, and readability scoring.
Similar plugins
More in ContentDub
A Payload CMS plugin that automatically creates and manages shortlinks using Dub.
Nested Docs Page Tree
Adds a nested tree view for managing documents in Payload CMS.
Puck visual page builder
Integrate Puck visual page builder with Payload CMS for drag-and-drop editing.
Structured Markdown
Enables structured Markdown editing and rendering with advanced authoring features.
ISR revalidation
Integrates ISR-style cache revalidation into Payload CMS for Next.js.