The purpose of engagement plans (EP) in Sitecore is the automation of work with visitors to our website. In this article, we will select a very simple scenario. The user enters the website, fills in the form, into which he enters personal information and e-mail and then clicks the sign in to EP button. We will create a simple EP, which will send the visitor a thank you e-mail once the visitor clicks on the sign in to EP. Signing in can either occur programmatically or based on a Sitecore campaign. In this example, we will show you signing in to EP programmatically.

We will first prepare EP: using the Marketing Control Panel tool, open the Engagement Plans file and enter a new EP. Sitecore uses Silverlight for suggestions and reports. Therefore, it does not work in the Chrome browser, which does not support this technology. I recommend using the Firefox browser. By using the Design button, we can suggest it something like this:


On the figure above, we can see that our EP contains 2 statuses (initial-state and email-sent). The status, initial-state is the initial state of the EP, into which we will attempt to enter the visitor. For this status, we will see 5 min in the lower right hand corner. This means that if the user is assigned into this status, he is moved after 5 minutes, which in our case means that the move-next condition is assessed. The condition does not decide anything. It is always true, therefore, the visitor moves directly to the next status called email-sent. During the transfer from the move-next condition to the email-sent status, we see the number 1. This means that during the transfer, a certain action is called upon. In our case, it deals with the sending of an e-mail, which the editor can edit. Editing looks like this:


The figure above shows the edit window, into which the editor can enter the following information:

  • From Name – name of sender
  • From Address – address of sender
  • Subject – subject of e-mail
  • Base Site URL – homepage, which is used in case of entering a link into the body of the message
  • Body – body of message
  • To Address Type – here, the editor chooses whether the e-mail is sent onto a fixed e-mail address, which he enters or onto the e-mail address of the visitor. In our example, we will try sending the e-mail onto the address of the visitor. Be careful here. Sitecore sends an e-mail to the visitor’s unique identifier, not to an e-mail address, which is filled out in MongoDB, see figure below.

Now, once the EP is suggested, we can create a magical button, which will sign the visitor in to our EP. In the example, we will use the e-mail address of the visitor as the recipient’s e-mail address. You can read about how to assign the visitor’s e-mail address in my previous article here.

We prepared rendering into Sitecore, which only draws a button into the HTML and using POST it sends it onto the server. The code, which sign the visitor in to the EP looks like this:

public ActionResult EnrollInEngagementPlan(string command)
    if (command != "enrollVisitor")
        return View("/Views/Project/Boxes/Enroll In Engagement Plan.cshtml");
    const string stateId = "{6E1F6979-CD94-49D0-8D9D-AED63779CFF4}";
    var stateItem = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(stateId));
    if (stateItem == null)
        return Content("State not found");
    // Get manager
    var managerInContext = Sitecore.Analytics.Tracker.Current.Session.CreateAutomationStateManager();
    // Check if visitor is already enrolled in Engagement plan
    var currentState = managerInContext.GetCurrentStateInPlan(stateItem.ParentID);
    if (currentState != null)
        // Move to different state
        managerInContext.MoveToEngagementState(stateItem.ParentID, stateItem.ID);
        // Enroll in provided state
        managerInContext.EnrollInEngagementPlan(stateItem.ParentID, stateItem.ID);
    return Content("You are enrolled.");

The constant, stateId contains the initial-state ID item, which is directly under the root of our EP test.

The entire EP course would look like this.

The user opens the website, fills in his personal data:


After filling in his personal data, he clicks on the Enroll Current Visitor button and he will receive a message saying that he has been sign in to the EP:


Once the visitor’s session expires, he is entered into the selected status in the EP, as can be seen in the figure below.


This is when the visitor’s 5 minute trigger starts running, which leads to the sending of an e-mail. The e-mail leaves in the form in which we defined it in suggested EP. The e-mail goes to the visitor’s e-mail address:


Once the e-mail has been sent, the visitor moves to the email-sent status:


This example showed us how to define a simple EP and how to sign a visitor of the website into it.