Sitecore 7.5 Analytics and user manipulation in Engagement plans

I have recently had the interesting and challenging task of upgrading a Sitecore 7.2 installation to the newest Sitecore 7.5.  In the project we were extensively using Analytics code which had to be updated. That is where the fun began.

In our solution we had to manipulate users in engagement plans. Users had to be added, removed or moved between engagement plan states from the code. In order to do that we had to change the code to adapt it to the new API. Here are the changes.

1. Add a Sitecore user to an engagement plan.



It can be done in two different ways. Assuming you have a list of User Names that you want to add to an engagement plan you can do it this way.

The idea behind this was to perform a bulk-import of users/contacts into an Engagement Plan from an external source. For other scenarios we have to use the new API that adds Contacts to the Engagement Plan using their ContactId.

A great help in how do I identify my user was this blog post by Nick Wesselman.

After the first line of code the Contact has been identified. If it is a new Contact and does not exist in the Contacts Collection in xDB it will be saved in the shared session state.

If it exists in the xDB then it will be locked to the shared session state.

The third line will put the Contact Entry in the Engagement plan (in the shared session state, thus no changes in xDB). Only when the xDB is synchronized the results will be visible and the Contact will exist in the Engagement Plan state.

2. Removing a user from an engagement plan



3. Moving a contact from an engagement plan state to another one



The explanation related to user identification and the whole process described in the Add action applies to the remove and move user actions.

I hope that this post will save someone some time. Ask away and if I can I will answer.

Avatar photo

Alin Parjolea

System Developer at Pentia. I have been involved in small and large scale projects using Sitecore and .Net for the last 4 years. I am Sitecore certified developer since 2009. I have a Master degree in Computer Science from University of Southern Denmark. More detailed info about me can be found on my Facebook and LinkedIn pages.

2 thoughts on “Sitecore 7.5 Analytics and user manipulation in Engagement plans

    • I will bring some small updates as this upgrade has a ton of changes. It might help the next guy trying to do this 🙂

Comments are closed.