Sitecore Analytics rules with custom user properties

This post will show how to create an Engagement plan rule that uses custom fields. The idea is that the users have custom fields on their profile related to newsletter distribution groups.

The goal is to create an engagement plan where we have a rule condition saying something like this :


The engagement plan using this condition has a user in the initial state, a condition validator and a second state where the user will be put if the condition validates.  An email will be sent after the validation (in this case).


The “Unsubscribe Date” is a custom field set on the user profile. “Include time in comparison” is used to include or exclude the time when we compare the dates. That is because the date time is saved in Sitecore format “yyyymmddThhmmss” and for some fields the comparison may need to exclude the time and only compare the dates.

On the user profile in the core database the following custom fields are added:


After defining the custom fields we need to set up the Sitecore rule under this item:



The “TimeComparisonInclusion” and “UserCustomFields” subitems are just empty standard templates that will be used when editing the rule in the engagement plan Designer.

The text of the UserDateTimeFieldComparer rule is like this:

“Where the User [DateField,Tree,root={3A3D6165-A03D-4413-ACC7-1DE75F4E9C42}&setRootAsSearchRoot=true,custom date field] [operatorid,Operator,,compares to] [StartDate, DateTime,,date] and [IncludeTimeInComparison, Tree,root={7CF3EC01-4FEB-4181-8875-87A0818CEF70}&setRootAsSearchRoot=true,include time in comparison ]”

where the “{3A3D6165-A03D-4413-ACC7-1DE75F4E9C42}” and “{7CF3EC01-4FEB-4181-8875-87A0818CEF70}” IDs are the “TimeComparisonInclusion” and “UserCustomFields” item IDs.

This is the Sitecore part of the whole rule. The code that actually performs the verification comes next.

In the UserDateTimeFieldComparerCondition class we have defined two enums that are representing the two constraints in the rule : “TimeComparisonInclusion” and “UserCustomFields”.

The  constructor instantiates two dictionaries that bind the two enum constraints to the sitecore items.

We also define some properties that are used to read the values of the inserted parameters in the rule.

The execute method reads the parameters and performs the comparison.

Well, that was it.

Now you have a nice example of how to connect user profile custom fields to an engagement plan.


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.