PHPackages                             livehand/abtestcraft - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. livehand/abtestcraft

ActiveCraft-plugin[Utility &amp; Helpers](/categories/utility)

livehand/abtestcraft
====================

A/B testing for Craft CMS - test page variations and track conversions with statistical significance

1.0.0(5mo ago)0391[2 issues](https://github.com/livehanddotcom/abtestcraft/issues)[1 PRs](https://github.com/livehanddotcom/abtestcraft/pulls)proprietaryPHPPHP &gt;=8.2

Since Jan 11Pushed 5mo agoCompare

[ Source](https://github.com/livehanddotcom/abtestcraft)[ Packagist](https://packagist.org/packages/livehand/abtestcraft)[ RSS](/packages/livehand-abtestcraft/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (8)Versions (2)Used By (0)

ABTestCraft Plugin for Craft CMS
================================

[](#abtestcraft-plugin-for-craft-cms)

A/B testing for Craft CMS 5 - test page variations and track conversions with statistical significance.

**Website:** [abtestcraft.com](https://abtestcraft.com)

Features
--------

[](#features)

- **Server-Side Testing**: No page flicker. Visitors are assigned variants before the page renders
- **Entry-Based Variants**: Use Craft's native entry system - test entire pages, not just CSS tweaks
- **Multi-Goal Tracking**: Track multiple conversion types per test (forms, phone clicks, emails, downloads, page visits)
- **Statistical Significance**: Chi-squared test with configurable confidence threshold (80-99%)
- **Smart Form Tracking**: Native integration with Freeform and Formie plugins
- **GA4/GTM Integration**: Push events to dataLayer for analytics tracking
- **SEO Protection**: Automatic noindex/canonical tags on variant entries
- **Cascade Support**: Child pages inherit parent's variant assignment
- **Privacy-Friendly**: First-party cookies only, no external trackers

Requirements
------------

[](#requirements)

- Craft CMS 5.0.0 or later
- PHP 8.2 or later

Installation
------------

[](#installation)

1. Install with Composer:

```
composer require livehand/abtestcraft
```

2. Install the plugin from the Craft Control Panel under **Settings &gt; Plugins**, or via CLI:

```
./craft plugin/install abtestcraft
```

Quick Start
-----------

[](#quick-start)

### 1. Create Your Test Pages

[](#1-create-your-test-pages)

Create two entries in Craft CMS:

- **Control**: Your original page
- **Variant**: The variation you want to test

### 2. Create a Test

[](#2-create-a-test)

1. Go to **ABTestCraft** in the control panel sidebar
2. Click **New Test**
3. Enter a name and select your control/variant entries
4. Configure your goals (what counts as a conversion)
5. Set your traffic split (default 50/50)
6. Click **Start Test** when ready

### 3. View Results

[](#3-view-results)

Results update in real-time as visitors convert. The plugin calculates:

- Conversion rates per variant
- Statistical significance (Chi-squared test)
- Confidence level
- Relative improvement percentage
- Estimated days to significance

Goal Types
----------

[](#goal-types)

### Phone Click

[](#phone-click)

Tracks clicks on `tel:` links.

### Email Click

[](#email-click)

Tracks clicks on `mailto:` links.

### Form Submission

[](#form-submission)

Tracks form submissions with smart detection:

- **Smart Mode**: Auto-detects Freeform/Formie success events
- **Advanced Mode**: Configure CSS selectors for custom forms

### File Download

[](#file-download)

Tracks downloads by file extension (PDF, DOC, XLS, ZIP, etc.).

### Page Visit

[](#page-visit)

Tracks visits to a specific URL. Match types: exact, starts with, contains.

### Custom Event

[](#custom-event)

Track custom conversions via JavaScript:

```
// In your template or JavaScript
window.ABTestCraft.trackConversion('purchase_complete');
```

Configuration
-------------

[](#configuration)

Configure global settings in **ABTestCraft &gt; Settings**:

SettingDefaultDescriptionCookie Duration30 daysHow long visitor assignments persistTrack Phone ClicksOnAutomatically track tel: linksTrack Email ClicksOnAutomatically track mailto: linksTrack Form SubmissionsOnAutomatically track form submitsTrack File DownloadsOnAutomatically track file downloadsConversion Rate Limit10/minMax conversions per IP per test per minuteConversion CountingPer Goal TypeHow to count multiple conversionsSignificance Threshold95%Confidence level to declare significanceMinimum Detectable Effect10%Smallest relative improvement to detectEnable dataLayerOffPush events to GA4/GTMTwig Variables
--------------

[](#twig-variables)

Access split test information in your templates via `craft.abtestcraft`:

```
{# Check if there's an active test on this page #}
{% if craft.abtestcraft.hasActiveTest() %}
    {# Get current variant ('control' or 'variant') #}
    {% set variant = craft.abtestcraft.getActiveVariant() %}

    {# Conditional content based on variant #}
    {% if craft.abtestcraft.isShowingVariant() %}
        {# Variant-specific content #}
    {% endif %}
{% endif %}

{# For cascade support - get parent accounting for variant #}
{% set parent = craft.abtestcraft.getParent(entry) %}

{# Get children accounting for variant borrowing #}
{% set children = craft.abtestcraft.getChildren(entry) %}

{# Check if current page is a cascaded child #}
{% if craft.abtestcraft.isCascaded() %}
    ...
{% endif %}
```

Permissions
-----------

[](#permissions)

The plugin registers two permissions:

- **Manage AB tests** (`abtestcraft:manageTests`): Create, edit, start, pause, complete, and delete tests
- **View test results** (`abtestcraft:viewResults`): View test statistics and results

GA4/GTM Integration
-------------------

[](#ga4gtm-integration)

When enabled, the plugin pushes events to `window.dataLayer`:

### Events

[](#events)

EventWhen FiredParameters`abtestcraft_impression`Visitor sees test`abtestcraft_name`, `abtestcraft_variant``abtestcraft_conversion`Conversion recorded`abtestcraft_name`, `abtestcraft_variant`, `conversion_type`### GTM Setup

[](#gtm-setup)

1. Create a Custom Event trigger for `abtestcraft_conversion`
2. Create Data Layer Variables for each parameter
3. Create a GA4 Event tag with your event parameters
4. Create Custom Dimensions in GA4 for reporting

API Endpoints
-------------

[](#api-endpoints)

### Record Conversion

[](#record-conversion)

```
POST /actions/abtestcraft/track/convert

```

Parameters:

- `testHandle` (string, required): The test handle
- `conversionType` (string, required): phone, email, form, download, page, or custom
- `goalId` (int, optional): Specific goal ID

Requires CSRF token in request.

Console Commands
----------------

[](#console-commands)

```
# Rebuild cascade mappings (if entries were moved while plugin was disabled)
./craft abtestcraft/rebuild-cascade
```

How It Works
------------

[](#how-it-works)

1. **Visitor arrives**: Plugin checks if there's an active test for the requested URL
2. **Assignment**: Visitor is assigned to control or variant (persisted in cookie)
3. **Template swap**: If assigned to variant, the variant entry's template is rendered instead
4. **Tracking**: JavaScript tracks configured goals and sends conversions to the server
5. **Statistics**: Chi-squared test calculates statistical significance
6. **Notification**: Email sent when test reaches significance threshold

Data Retention &amp; Backup
---------------------------

[](#data-retention--backup)

### Database Tables

[](#database-tables)

The plugin creates the following tables that should be included in your backup strategy:

TablePurposeGrowth Rate`abtestcraft_tests`Test configurationsLow (manual creation)`abtestcraft_goals`Goal configurationsLow (tied to tests)`abtestcraft_visitors`Visitor assignmentsMedium (one per unique visitor per test)`abtestcraft_daily_stats`Aggregated statisticsLow (one row per day/variant/goal)`abtestcraft_rate_limits`Rate limiting cacheSelf-cleaning (auto-purges old entries)### Data Retention

[](#data-retention)

- **Visitor data**: Retained indefinitely until test is hard-deleted
- **Statistics**: Aggregated daily, raw impressions not stored
- **Completed tests**: Remain in database for historical reference
- **Trashed tests**: Soft-deleted, can be restored or permanently removed

### Archiving Old Data

[](#archiving-old-data)

For high-traffic sites, consider periodically:

1. Exporting completed test data to your analytics platform
2. Hard-deleting old tests via **ABTestCraft &gt; Completed &gt; Delete Permanently**
3. Monitoring the `abtestcraft_rate_limits` table size (auto-cleans but verify)

### Backup Recommendations

[](#backup-recommendations)

Include these tables in your database backups:

```
abtestcraft_tests
abtestcraft_goals
abtestcraft_visitors
abtestcraft_daily_stats
```

The `abtestcraft_rate_limits` table is transient and doesn't need to be backed up.

Best Practices
--------------

[](#best-practices)

### Test Duration

[](#test-duration)

- Run tests for at least 7 days to account for weekly traffic patterns
- Wait for statistical significance before declaring a winner
- Don't peek and stop early - this inflates false positive rate

### Traffic Requirements

[](#traffic-requirements)

Sample size needed depends on your baseline conversion rate and minimum detectable effect:

- 5% baseline, 10% MDE: ~3,000 visitors per variant
- 2% baseline, 10% MDE: ~8,000 visitors per variant

### Goals

[](#goals)

- Track the metric that matters most to your business
- Enable one goal type per test for clearest results
- Use "Per Goal Type" counting for multi-goal tests

Support
-------

[](#support)

For bug reports and feature requests, please [open an issue](https://github.com/livehanddotcom/abtestcraft/issues).

License
-------

[](#license)

This plugin is licensed under the [Craft License](https://craftcms.github.io/license/).

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance70

Regular maintenance activity

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

173d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17930845?v=4)[livehand](/maintainers/livehand)[@Livehand](https://github.com/Livehand)

---

Top Contributors

[![livehanddotcom](https://avatars.githubusercontent.com/u/183508871?v=4)](https://github.com/livehanddotcom "livehanddotcom (2 commits)")

---

Tags

optimizationanalyticscraftcmscraft-pluginab-testingconversion-tracking

###  Code Quality

TestsCodeception

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/livehand-abtestcraft/health.svg)

```
[![Health](https://phpackages.com/badges/livehand-abtestcraft/health.svg)](https://phpackages.com/packages/livehand-abtestcraft)
```

###  Alternatives

[verbb/formie

The most user-friendly forms plugin for Craft.

102393.6k68](/packages/verbb-formie)[spicyweb/craft-neo

A Matrix-like field type with block hierarchy

393813.5k10](/packages/spicyweb-craft-neo)[verbb/comments

Add comments to your site.

13753.9k](/packages/verbb-comments)[verbb/navigation

Create navigation menus for your site.

92705.0k18](/packages/verbb-navigation)[verbb/vizy

A flexible visual editor field for Craft.

4250.4k](/packages/verbb-vizy)[verbb/hyper

A user-friendly links field for Craft.

24147.8k12](/packages/verbb-hyper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
