Sitecore DMS Engagement plans allow you to control some of the specific ways in which your website interacts and communicates with the visitors to your website. Think of engagement plans as a configurable flow state engine. It allows you to push the responsibility of automation to your customer.
Engagement plans are especially usefull when you have named visitors, ie users with a username and an email.
Engagement plans are controlled through the Sitecore.Analytics.Automation.VisitorManager class and the Sitecore.Analytics.Tracker class.
The Tracker class can be used for connecting a named user to the DMS visitor:
using Sitecore.Analytics; using Sitecore.Analytics.Automation; private void CheckAndSetTracker(string userName) { if (Tracker.IsActive) { Tracker.Visitor.ExternalUser = userName; } }
The userName is a fully qualified name, ie extranet\user.
To assign a user to an engagement plan, simply call VisitorManager.AddVisitor with the ID of the engagement plan state:
public bool AssignToEngagementPlan(User user, ID engagementPlanIdStartState) { bool addVisitor = VisitorManager.AddVisitor(user.Name, engagementPlanIdStartState); return addVisitor; }
The User is the Sitecore.User.
usually you would assign the user to the first step of your engagement plan, but you can in fact assign the user to any state you wish.
You can also move a visitor from one state to another:
VisitorManager.MoveVisitor(userName, source, destination);
You can also search for a specific user in an engagement plan to see is the user is alreay assigned to any state in that engagement plan:
private bool UserIsInAnyEngagementPlanState(string userName, ID engagementPlan, out ID stateId) { var result = false; stateId = null; foreach (Item state in GetEngagementPlanItem(engagementPlan).Children) { result = VisitorManager.GetStateVisitors(state.ID).Any(visitor => visitor.Equals(userName)); if (result) { stateId = state.ID; break; } } return result; }
That’s basically it. It’s very easy to work with once you get the hang of it.
READ MORE:
- Sitecore Engagement Plan Cookbook.
- Sitecore Engagement Plans as an Audience Segmentation Tool by Mike Casey.
- Applying Advanced Sitecore DMS Capabilities: Engagement Automation by Aaron Branson, Roundedcube.
