Skip to content

RL: A/B & Multivariate Testing for Drupal

A/B and multivariate testing for Drupal using reinforcement learning. Each page view is a trial, each conversion is a reward, and the algorithm continuously shifts traffic to whichever variant is winning. RLHF-style feedback loop, no fixed horizons, no third-party SaaS.

3D Posterior Landscape showing variant performance over time

What you can A/B test

  • RL: A/B Test Views Content (rl_sorting): reorders any Drupal View by engagement. A Views sort plugin calls Thompson Sampling with content IDs as arms and reorders rows before rendering; turns and rewards are tracked client-side.
  • RL: A/B Test Page Titles (rl_page_title, bundled submodule): tests page titles for nodes, Views pages, and any controller. Hooks into the preprocess pipeline to swap the visible title and <title> tag. A vertical tab on content entity edit forms lets editors manage variants inline.
  • RL: A/B Test Menu Links (rl_menu_link, bundled submodule): tests labels in any menu link. Walks the menu tree at render time and swaps link titles with the winning variant. A vertical tab on the menu link edit form lets editors add alternatives.
  • DXPR Builder integration: renders all variant slots into the page HTML (so the page stays fully cacheable) and uses Drupal.rl.decide() on the client to pick and swap the winner.
  • Custom modules: RL provides base classes and services for building your own consumer modules. See the Building a Consumer Module guide.

Features

  • Multivariate by default: 2 to thousands of variants, no manual configuration
  • Real-time RLHF loop: visitor clicks update the model on every page
  • Fast HTTP REST API: optimised JSON endpoint at rl.php
  • Admin reports: per-experiment performance, traffic, and confidence at /admin/reports/rl
  • Service-based architecture: extensible decorators, custom variant selectors
  • Data sovereignty: no cloud, no SaaS, all data stays in your Drupal database
  • GDPR-friendly tracking: only anonymous interaction counts, no user IDs or cookies

Why RL instead of fixed-horizon A/B testing?

Traditional A/B tests run for a fixed window (say two weeks) and split traffic 50/50 the whole time, even when one variant is obviously losing. RL turns the experiment into a feedback loop: every click adjusts the model, traffic shifts toward the leader as soon as evidence emerges, and the test never has to "end". You can run dozens or thousands of variants simultaneously (true multivariate testing), and a newly added variant is in play on the next render with no manual setup.

How it works

RL uses a multi-armed bandit (Thompson Sampling). Each variant has a reward distribution; on each render the algorithm samples from the distributions and picks the highest sample. Wins update the distribution toward higher rewards; losses update toward lower. Algorithm details: ThompsonCalculator.php.

Use cases

  • A/B test any content variation without third-party SaaS
  • Multivariate test dozens or thousands of variants at once
  • Continuous optimisation: tests never end, the model keeps learning
  • Recommendations: rank items by real engagement
  • Smart sorting: reorder lists, accordions, or FAQs by visitor engagement
  • Feature flags: route users to variants based on observed reward, not coin flip

Resources