This project is not covered by Drupal’s security advisory policy.

A/B Paragraphs is a lightweight module for running basic A/B tests using the Drupal Paragraphs system. Editors can test two content variants, track user interaction, and send simple analytics events.

Features

A/B Paragraphs adds a new Paragraph type called A/B Test that allows editors to run basic A/B tests within Drupal content. Each test consists of Variant A and Variant B, with configurable display ratios (e.g., 50/50, 90/10).

Only one variant is shown to a user per session, and the rendering is handled on the frontend using JavaScript. The module suggests tracking code for each variant based on links found in the content. Editors are free to edit or replace these suggestions.

The module does not perform analytics or reporting itself but allows you to send click events to your analytics tool (e.g., Google Analytics or Matomo).

  • A/B Test Paragraph type with two content variants
  • Session-based rendering: one variant per user per session
  • Unique ID and configurable distribution ratio
  • Separate tracking code fields for each variant
  • Tracking code suggestions based on link analysis
  • Show event tracking on pageload when a variant is shown
  • Click event tracking via onclick attributes

Post-Installation

After installation, the module automatically creates a new Paragraph type called ab_test and adds the following fields:

  • field_variant_a
  • field_variant_b
  • field_tracking_code_a
  • field_tracking_code_b
  • field_unique_id
  • field_distribution

Manual configuration is required to enable and arrange the fields:

  • Go to: /admin/structure/paragraphs_type/ab_test/form-display
  • Then to: /admin/structure/paragraphs_type/ab_test/display

Ensure that the tracking code fields use the Plain text (multiple lines) widget and that all necessary fields are enabled, visible, and editable.

Additional Requirements

This module requires the Paragraphs module.

This module is compatible with any analytics solution that accepts custom events. Common choices include:

Similar projects

For more advanced A/B testing functionality—including multivariate testing, targeting, personalization, and analytics dashboards—consider:

  • VWO – Full-featured testing, heatmaps, and audience segmentation
  • Optimizely – Robust experimentation platform with strong Drupal integration

Unlike those platforms, A/B Paragraphs is minimal and does not require external services.

Supporting this Module

If you find this module useful and want to support future development, feel free to reach out via the issue queue or contribute code and feedback.

Community Documentation

Documentation, usage guides, and examples will be added as the module evolves. Contributions are welcome.

Known issues / to do:

  • It should not be possible to nest an A/B Test paragraph inside another A/B Test paragraph.
  • Unclear whether tracking code suggestions work for all link types (e.g., entity references).
  • Tracking code suggestions are currently tailored to Matomo only. When another analytics provider (such as Google Analytics) is selected, the suggestions should adjust accordingly.
  • Tracking code suggestions may not work correctly when multiple A/B Test paragraphs are used on the same page. It might not be desirable to support more than one A/B test per page.
  • The module contains some temporary logging code, which should be removed in a future release.
Supporting organizations: 
Maintenance
Maintenance and development

Project information

Releases