A/B Split Testing
OM_ABTest manages campaign variants. An A/B test is a parent campaign (control) plus one or more variant campaigns.
How It Works
- Admin creates a campaign — it becomes the control
- Admin creates variants with different subject lines, content, or sender name
- On send, OMailer splits the list: each variant gets its configured percentage; remainder goes to control
- After the evaluation window (configurable in hours), OMailer scores each variant by the chosen metric
- The winner is automatically sent to all remaining subscribers
Database Columns (on om_campaigns)
| Column | Type | Notes |
|---|---|---|
ab_parent_id | BIGINT UNSIGNED | ID of parent/control campaign |
ab_split_pct | TINYINT | % of list this variant receives (0–100) |
ab_winner_metric | ENUM | open_rate or click_rate |
ab_eval_hours | SMALLINT | Hours until winner selection |
ab_status | ENUM | none, control, variant, winner, loser |
ab_sent_at | DATETIME | When this variant batch was sent |
PHP API
php$ab = new OM_ABTest();
// Create a variant from an existing campaign
$variant_id = $ab->create_variant(
$parent_campaign_id,
[
'subject' => 'Different subject line',
'html_content' => '<p>Variant B content...</p>',
],
30, // split_pct: give this variant 30% of list
'open_rate', // winner_metric
24 // eval_hours: pick winner after 24 hours
);
// Check if a campaign is part of an A/B test
$is_ab = $ab->is_ab_campaign( $campaign_id ); // bool
// Get all campaigns in a test
$variants = $ab->get_test_campaigns( $campaign_id );
// Manually declare winner (skips evaluation window)
$ab->evaluate( $parent_campaign_id );
Cron
OMailer checks all active A/B tests every hour via om_check_ab_tests. When ab_eval_hours has passed, it calls evaluate() which:
- Calculates open rate or click rate for each variant
- Marks the best as
winner, others asloser - Sends the winner to subscribers who haven't received any variant yet
