Menu
Amazon Pinpoint
Developer Guide

Creating Campaigns

To help increase engagement between your app and its users, use Amazon Pinpoint to create and manage push notification campaigns that reach out to particular segments of users.

For example, your campaign might invite users back to your app who haven’t run it recently or offer special promotions to users who haven’t purchased recently.

A campaign sends a tailored message to a user segment that you specify. The campaign can send the message to all users in the segment, or you can allocate a holdout, which is a percentage of users who receive no messages.

You can set the campaign schedule to send the message once or at a recurring frequency, such as once a week. To prevent users from receiving the message at inconvenient times, the schedule can include a quiet time during which no messages are sent.

To experiment with alternative campaign strategies, set up your campaign as an A/B test. An A/B test includes two or more treatments of the message or schedule. Treatments are variations of your message or schedule. As your users respond to the campaign, you can view campaign analytics to compare the effectiveness of each treatment.

For more information, see Campaigns.

Creating Standard Campaigns

A standard campaign sends a custom push notification to a specified segment according to a schedule that you define.

Creating Campaigns With the AWS SDK for Java

The following example demonstrates how to create a campaign with the AWS SDK for Java.

Copy
import com.amazonaws.services.pinpoint.AmazonPinpointClient; import com.amazonaws.services.pinpoint.model.Action; import com.amazonaws.services.pinpoint.model.CampaignResponse; import com.amazonaws.services.pinpoint.model.CreateCampaignRequest; import com.amazonaws.services.pinpoint.model.CreateCampaignResult; import com.amazonaws.services.pinpoint.model.Message; import com.amazonaws.services.pinpoint.model.MessageConfiguration; import com.amazonaws.services.pinpoint.model.Schedule; import com.amazonaws.services.pinpoint.model.WriteCampaignRequest; import java.util.ArrayList; import java.util.List; public class PinpointCampaignSample { public CampaignResponse createCampaign(AmazonPinpointClient client, String appId, String segmentId) { Schedule schedule = new Schedule() .withStartTime("IMMEDIATE"); Message defaultMessage = new Message() .withAction(Action.OPEN_APP) .withBody("My message body.") .withTitle("My message title."); MessageConfiguration messageConfiguration = new MessageConfiguration() .withDefaultMessage(defaultMessage); WriteCampaignRequest request = new WriteCampaignRequest() .withDescription("My description.") .withSchedule(schedule) .withSegmentId(segmentId) .withName("MyCampaign") .withMessageConfiguration(messageConfiguration); CreateCampaignRequest createCampaignRequest = new CreateCampaignRequest() .withApplicationId(appId).withWriteCampaignRequest(request); CreateCampaignResult result = client.createCampaign(createCampaignRequest); System.out.println("Campaign ID: " + result.getCampaignResponse().getId()); return result.getCampaignResponse(); } }

When you run this example, the following is printed to the console window of your IDE:

Copy
Campaign ID: b1c3de717aea4408a75bb3287a906b46

Creating A/B Test Campaigns

An A/B test behaves like a standard campaign, but enables you to define different treatments for the campaign message or schedule.

Creating A/B Test Campaigns With the AWS SDK for Java

The following example demonstrates how to create an A/B test campaign with the AWS SDK for Java.

Copy
import com.amazonaws.services.pinpoint.AmazonPinpointClient; import com.amazonaws.services.pinpoint.model.Action; import com.amazonaws.services.pinpoint.model.CampaignResponse; import com.amazonaws.services.pinpoint.model.CreateCampaignRequest; import com.amazonaws.services.pinpoint.model.CreateCampaignResult; import com.amazonaws.services.pinpoint.model.Message; import com.amazonaws.services.pinpoint.model.MessageConfiguration; import com.amazonaws.services.pinpoint.model.Schedule; import com.amazonaws.services.pinpoint.model.WriteCampaignRequest; import com.amazonaws.services.pinpoint.model.WriteTreatmentResource; import java.util.ArrayList; import java.util.List; public class PinpointCampaignSample { public CampaignResponse createAbCampaign(AmazonPinpointClient client, String appId, String segmentId) { Schedule schedule = new Schedule() .withStartTime("IMMEDIATE"); // Default treatment. Message defaultMessage = new Message() .withAction(Action.OPEN_APP) .withBody("My message body.") .withTitle("My message title."); MessageConfiguration messageConfiguration = new MessageConfiguration() .withDefaultMessage(defaultMessage); // Additional treatments WriteTreatmentResource treatmentResource = new WriteTreatmentResource() .withMessageConfiguration(messageConfiguration) .withSchedule(schedule) .withSizePercent(40) .withTreatmentDescription("My treatment description.") .withTreatmentName("MyTreatment"); List<WriteTreatmentResource> additionalTreatments = new ArrayList<WriteTreatmentResource>(); additionalTreatments.add(treatmentResource); WriteCampaignRequest request = new WriteCampaignRequest() .withDescription("My description.") .withSchedule(schedule) .withSegmentId(segmentId) .withName("MyCampaign") .withMessageConfiguration(messageConfiguration) .withAdditionalTreatments(additionalTreatments) .withHoldoutPercent(10); // Hold out of A/B test CreateCampaignRequest createCampaignRequest = new CreateCampaignRequest() .withApplicationId(appId).withWriteCampaignRequest(request); CreateCampaignResult result = client.createCampaign(createCampaignRequest); System.out.println("Campaign ID: " + result.getCampaignResponse().getId()); return result.getCampaignResponse(); } }

When you run this example, the following is printed to the console window of your IDE:

Copy
Campaign ID: b1c3de717aea4408a75bb3287a906b46