API Reference

Get Campaign A/B Result

GET /campaigns/:id/ab — retrieve the A/B winner evaluation for a campaign.

GET/campaigns/:id/ab

Returns the A/B winner evaluation for a campaign that has A/B testing enabled. MailBlastr runs a two-proportion z-test over the per-variant open, click, or reply outcomes recorded in the tracking tables, and returns which variant won, how confident the result is, and detailed per-variant metrics. The metric field reflects the ab_metric set on the campaign (open, click, or reply). The confidence field is low when the sample is too small to trust, medium when the winner leads but it is not conclusive, and high when the result is statistically significant (p < 0.05 with at least 20 sends per arm). If the variants are tied or one arm has no sends, the winner defaults to A and fallback is true.

Path parameters
idstringrequired

The campaign ID.

import { MailBlastr } from 'mailblastr';

const mb = new MailBlastr('mb_xxxxxxxxx');

const { data, error } = await mb.campaigns.ab('8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90');
console.log({ data, error });

Response

{
  "object": "campaign_ab",
  "campaign_id": "8f5c2a1e-7b3d-4f9a-9c12-2e6d4a7b8c90",
  "metric": "open",
  "a": {
    "variant": "A",
    "sent": 120,
    "conversions": 36,
    "rate": 0.3
  },
  "b": {
    "variant": "B",
    "sent": 118,
    "conversions": 47,
    "rate": 0.3983050847457627
  },
  "winner": "B",
  "fallback": false,
  "lift": 0.3276785714285714,
  "zScore": 2.14,
  "pValue": 0.0162,
  "confidence": "high",
  "reason": "variant B wins on open (p=0.016)"
}
Errors: not_found if the campaign does not exist or is not yours; validation_error if the campaign does not have A/B testing enabled.