With the introduction of the xDB in Sitecore 7.5, Sitecore also changed the analytics API. The VisitorManager have been replaced by the Tracker.
The Tracker is one of the base API’s for Sitecore the new Sitecore Experience Platform (the new name for Sitecore DMS, which was the new name for Sitecore OMS – do you follow me?) and the API handles the tracking of users in Sitecore.
For automatic engagement plan handling, this means that instead of using the VisitorManager to enroll users in your engagement plan, you use the Tracker and the AutomationStateManager:
using System.Linq; using Sitecore.Analytics; using Sitecore.Analytics.Automation.Data; using Sitecore.Analytics.Automation.MarketingAutomation; using Sitecore.Data.Items; public void AddUserToEngagementPlan(string user, Item engagementPlan) { Tracker.Current.Session.Identify(user); AutomationStateManager manager = Tracker.Current.Session.CreateAutomationStateManager(); manager.EnrollInEngagementPlan(engagementPlan.ID, engagementPlan.Children.First().ID); }
Parameter user is the complete username with domain (for example extranet\bp). The engagementPlan is the engagementPlan item.
The remove a user from an engagement plan you simply call RemoveFromEngagementPlan:
public void RemoveUserFromEngagementPlan(string user, Item engagementPlan) { Tracker.Current.Session.Identify(user); AutomationStateManager manager = Tracker.Current.Session.CreateAutomationStateManager(); manager.RemoveFromEngagementPlan(engagementPlan.ID); }
Thanks to Alin Parjolea for the code.
MORE TO READ:
- Engagement Plans by Sitecore
- Sitecore 7.5 Analytics and user manipulation in Engagement plans by Alin Parjolea
Pingback: Modifying Code to Add a Visitor to an Engagement Plan when upgrading from Sitecore 6.6 to 8.1 | Sitecore Sandbox