marketing automation multiple enrollments SitecoreHow-To

Sitecore 9.1 Marketing Automation - Repeated and concurrent contact enrollments

Sitecore 9.1 was released with a number of new Marketing Automation features and enhancements. Some of the highly anticipated features are:

  • Enrollment controls that define how many times a contact can be enrolled in a campaign
  • Campaign templates and a number of predefined templates for contact Acquisition, Conversion, Win Back and Account Development
  • Ability to enroll contacts from a list and remove individual contacts from automation plan

Out of the box, Sitecore 9.0 does not allow to enroll a contact to the same automation plan multiple times. Generally speaking a plan like Abandoned Cart (where a customer fails to complete an order, an automated marketing email will be sent to the recipient) would only be triggered once for each contact.

This post is aimed to clarify how Sitecore 9.1 addresses the ability to enroll a contact multiple times.

Sitecore 9.1 comes with a new Maximum Enrollments property available in Marketing Automation UI

Marketing Automation UI

It is possible to specify an exact number of enrollments (10 in the above sample plan) or set it to Unlimited. Looks simple but in fact, there are more details to consider.

Let’s have a close look at automation plan definition in Sitecore 9.1 and 9.0.

marketing automation plan definition

Notice new properties added comparing to Sitecore 9.0 are NewEnrollmentRegulatorType and its param MaxEnrollmentCount. Changes in Marketing Automation UI will be saved with it. When you create new MA plan default value for NewEnrollmentRegulatorType is null, meaning an Unlimited number of enrollments. There are two more extremely important properties: ReentryMode (default: 0) and ContextKeyFactory (default: Null) both available since Sitecore 9.0

If you give it a try and save a plan with Unlimited number of enrollments (or NewEnrollmentRegulatorType and MaxEnrollmentCount in place) it wont work. Any contact will be enrolled to such plan only once. Unfortunately there is a bug in Sitecore 9.1 (ID: 297306 if you need to request hotfix) which sets ReentryMode to 0 by default.

ReentryMode set to 0 (None), will prevent Sitecore from taking NewEnrollmentRegulatorType into account.

With ReentryMode set to 0, Marketing Automation engine EventProcessor will not allow plan entry if <AutomationPlanExit> contact facet has such plan listed at least once, i.e. if a contact has already been processed by a plan, it will not be enrolled again to the same plan. If a contact is already in the plan, a second enrollment will not be allowed.

ReentryMode set to 1 (Single) solves the problem.

You can change the default value for ReentryMode and set it to 1 (Single). In this mode Sitecore will allow multiple enrollments and will respect the implementation of NewEnrollmentRegulatorType and MaxEnrollmentCount param. With hotfix ReentryMode will be set to Single by default. Default NewEnrollmentRegulatorType implementation compares the number of plan exits for a contact (as defined by <AutomationPlanExit> contact facet) against MaxEnrollmentCount value set in definition.

It is slightly confusing that Single ReentryMode and MaxEnrollmentCount come together, but it makes perfect sense. Single mode is aimed to enable one-to-many enrollments for a given contact but a Single enrollment at the same time. I.e. contact has to exit a plan before it can enter it again.

The last but not least value available for ReentryMode is 2, meaning Multiple.

With Multiple mode you can make contact enrolled multiple times at the same time. I.e. contact does not have to exit a plan before it can enter it again. In order to enable such mode, you will have to implement ContextKeyFactoryType and manually set it in the definition. This option is available since Sitecore 9.0 initial release. ContextKeyFactorType will need to provide a unique contextKey that will help Sitecore understand how to treat multiple simultaneous enrollments for individual contact.

A good example would be Review Your Purchase automation, where a contact is invited by email to review order items in 2 weeks since an order is placed and obviously another order can be placed at the same time that we also want a review made. In this automation example OrderID is a perfect value for contextKey. Another post with ContextKeyFactoryType sample implementation will come later.

All above applies to interactions(events) based enrollment triggered by xConnect and Live Events processing.

What about manual enrollments from UI or enrollment with Marketing Automation Operations API?

The behavior is slightly different when a contact is enrolled from MA UI or MA Operations API. With default ReentryMode set to None (remember it is a bug), contact will be enrolled multiple times assuming its not in a plan already. I.e. it will behave much like a Single re-entry mode.

Another important difference is that in Single mode it will ignore the NewEnrollmentRegulatorType and MaxEnrollmentCount properties. So you can manually enroll a contact as many times as you need in both None and Single mode.

The behaviour for Multiple ReentryMode mode is similar. If a contact is already enrolled the following error is recorded in logs upon another enrollment from UI:

  2018-12-07 12:53:41.294 +03:00 [Error] Failed to create activity enrollment 
"ActivityEnrollmentKey: { ContactId: ...…..: "EnrollmentAlreadyExists" (EnrollmentAlreadyExists). Error message: null

MA engine will be retrying to add contact 100 times. A default AttempLimit value set for <MarketingAutomation.AttemptLimitWorkItemRegulator> which you can adjust it in sc.MarketingAutomation.PoolFilter.xml config

So you will still need to implement ContextKeyFactory to enroll the same contact by MA UI or Operations API multiple times simultaneously.

Sitecore documentation provides a great starting point to understand a number of scenarios when contact is enrolled in Automation plan.

Fly high with Sitecore 9.1!

Read more on marketing automation and Sitecore 9:


Do you need help with your Sitecore project?
VIEW SITECORE SERVICES