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.0- Unpacked size
- 181 kB
- License
- MIT
- Weekly downloads
- 179
- Last publish
- Aug 12, 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.
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.
Collaborative Comments
Adds document-level and field-level comments to the Payload admin panel, with @mentions, email notifications, resolution, multi-tenancy and locale filtering.
Presets
Save and apply reusable block configurations as presets in the Payload admin panel.
Create Ideal CMS
Scaffolds a production-ready Payload CMS monorepo preconfigured with the @focus-reactive plugin suite.
Similar plugins
More in ContentMenus
Adds a menus collection to Payload for building navigation with nested items, collection links, custom URLs, icons, and preview images.
Reservation and Booking Manager
Manage reservations and bookings through Payload CMS with conflict detection and scheduling.
Live Preview
Live preview for Payload CMS in Astro and any SSR/static frontend (SvelteKit, Nuxt, Next.js, plain HTML), patching the DOM without rebuilds.
FixedLink
Adds short links on your own domain to Payload documents, with links that keep working after slug changes through the FixedLink service.
Nested Docs Page Tree
Adds a nested tree view for managing documents in Payload CMS.
Redirects
Manage redirects directly within the Payload CMS admin panel.