APIs for A/B Testing

Use the following APIs to add A/B testing to your application or to access campaigns from within your application.

Note: The ABCtest Pipelet is used for Salesforce B2C Commerce analytics.

Scripting APIs

dw.campaign.ABTestMgr

Use this method for A/B testing.
Method Description
static isParticipant(testID : String, testGroupID : String) : boolean* Returns true if the current customer is a member of the specified A/B Test group, false otherwise.
static getAssignedABTestSegments(): Collection Returns the AB-test segments to which the current customer is assigned.
Example: the following shows the ABTestMgr.isParticipant B2C Commerce Script API used to show text with different background colors:
  • Control group participation on a green background
  • Test Segment A participation on an orange background
  • No participation on a grey background
<isif condition="${dw.campaign.ABTestMgr.isParticipant('Immediately','Control')}">
 <div style="background:green;">Control segment<br/><isprint value="${new Date()}" formatter="HH:mm:ss"/></div>
  <iselseif condition="${dw.campaign.ABTestMgr.isParticipant('Immediately','Test Segment A')}">
  <div style="background:orange;">Test segment<br/><isprint value="${new Date()}" formatter="HH:mm:ss"/></div>
  <iselse> <div style="background:#eee;">Not participating<br/><isprint value="${new Date()}" formatter="HH:mm:ss"/></div>
  </isif>

dw.campaign.ABTest

Use this class in custom code to determine to which A/B test segments the current customer is assigned.

Method Description
getID() : String Gets the A/B test ID.

dw.campaign.ABTestSegment

Use this class in custom code to determine to which A/B test segments the current customer is assigned.

Method Description
getID() : String Gets the A/B test segment ID.
getABTest() : ABTest Gets the A/B test.
isControlSegment() : boolean Returns true if the segment is the control group.

dw.order.PriceAdjustment

Use this class to determine if a price adjustment was generated by a promotion assigned to a Campaign or to an A/B test.

Method Description
getABTest() : ABTest Gets the A/B test.
getABTestID() : String Gets the A/B test ID.
getABTestSegment() : ABTestSegment Gets the A/B test segment.
getABTestSegmentID() : String Gets the A/B test segment ID.
isBasedOnABTest() : boolean Returns true if the price adjustment was generated by a promotion assigned to an A/B test.
Note: Promotion APIs also handle A/B testing.

Pipelet APIs

StartCheckout: This pipelet indicates when a customer has started the checkout process. Specifically, B2C Commerce registers a start checkout event for the specified basket. This event is tracked for A/B test statistics, but otherwise has no effect on the basket. B2C Commerce registers at most one checkout per basket per session.

If this pipelet is never executed, then all A/B test results show 0 checkouts for all segments. There is no need to change a site to execute this pipelet other than to enable analysis of the effect of A/B test experiences on the number of checkouts that are started. Adds to baskets and orders are counted regardless of whether or not this pipelet is executed.

Input Parameters: Basket : Basket (Required)

Why is this API not executed as a default in the Implementation?

The pipelet isn't executed by default because you need to decide when a checkout begins. The start of checkout could be as early as adding an item to the cart, or as late as when providing address or payment details. Each implementation can be different. Some implementations might simply follow the SiteGenesis pipeline schema using B2C Commerce pipelets, while others might use custom script programming within the scripting API. Also, not all of the checkout steps provided in SiteGenesis might be necessary. For example, there would be no need for the shipping address/method selection for software downloads or gift certificates. A checkout can actually include more steps, such as a verification web call to third party systems. Enabling you to decide where the checkout begins provides the flexibility to handle many scenarios.