Constant
Contact
API Guide

Create an A/B Test for an Email Campaign Activity

Make a POST call to the emails/activities/{campaign_activity_id}/abtest endpoint to create an A/B test for a primary email campaign activity. This method changes the campaign activity type from NEWSLETTER to AB_TEST and the type_code from 10 to 57

Request Body

You must include the following properties in the request body:

  • alternative_subject: The alternate email subject line to use for A/B testing. Currently, A/B tests support subject line only.

  • test_size: The percentage of contact recipients in the A/B Test. For example, if the value is 30, then 30% of contacts will receive the email campaign with subject line A, and 30% of contacts will receive the email campaign with subject line B. Valid values include 5 to 50 percent, inclusively.

  • winner_wait_duration: The number of hours Constant Contact waits after the A/B test is sent before determining the winning subject line. The winner is the subject line with the highest number of contact opens. After determining the winner, Constant Contact automatically sends the email campaign with the winning subject line to all the remaining contacts that did not participate in the A/B test.

Response Body

The following example shows the A/B test details returned in the response body:

{
    "alternative_subject": "{the alternate subject line to use}",
    "test_size": 10,
    "winner_wait_duration": 6
}

Authorization Requirements

User privileges: campaign:writeAuthorization scopes: campaign_data

Parameters

To create an A/B test for an email campaign, specify the email campaign_activity_id as a URL parameter.

Example Get Email Campaign Activity A/B Test

POST
https://api.cc.email/v3/emails/activities/{campaign_activity_id}/abtest

OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, " {\n     \"test_size\": 20,\n    \"alternative_subject\": \"Reminder: Big Sale Coming Soon!\",\n    \"winner_wait_duration\": 48\n}");
Request request = new Request.Builder()
  .url("https://api.cc.email/v3/emails/activities/0c53584f-113e-4b4c-b137-2d3a9e623818/abtest")
  .method("POST", body)
  .addHeader("Accept", "application/json")
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Bearer {access_token}")
  .build();
Response response = client.newCall(request).execute();

Response

{
    "alternative_subject": "Reminder: Big Sale Coming Soon!",
    "test_size": 20,
    "winner_wait_duration": 48
}

Schedule the A/B Test

To schedule a draft email campaign A/B test, make a POST call to /emails/activities/{campaign_activity_id}/schedules. This method requires campaign send user privileges.

Try it!

On this page