Sitecore has a large number of personalization and automation conditions. Understanding how conditions work and the data behind each condition is essential for successful experience optimization.
Contact profile values are stored in multiple locations in the Collections database. Historical data is stored in a ProfileScores facet for each interaction. It is also cached in a contact InteractionsCache facet. Final contact behaviour profile is stored in a contact Behavior profile facet.
Once any interaction matches profile pattern such pattern will be listed in the ProfileScores facet.
During one of our projects, we found some conditions don't behave according to our expectations.
We used the following out of the box conditions:
Doing some tests we found that both conditions are evaluated against all interactions available in Sitecore Collection DB. So if a contact has ever matched a pattern in the past, the above mentioned conditions will be evaluated to True. While this is reasonable in some profiling and personalization scenarios it did not quite match our project needs. Instead, we needed a condition like Where Contact Matches Pattern Card In Profile Now. i.e. instead of checking all historical data, we wanted to evaluate the current state (or final state of the contact).
Consider the following sample scenario where Product Profile score is collected as a summary between interactions.
|Product Profile score||Interaction 1||Interaction 2||Interaction 3||Interaction 4||Interaction 5|
Notice that for product B contact is progressing much better collecting higher profile score. According to project marketing definitions, this contact matched Awareness Stage pattern after interaction 1, Evaluation Stage pattern after Interaction 3, Action Stage pattern after Interaction 5.
If you were to use out of the box Where Contact Has Matched Pattern Card condition for personalization or segmentation to show different message for a contact matching Product B Awareness Stage you condition will always be True even when contact progressed to the Action Stage pattern match. Same issue will apply if you try to evaluate pattern match in the Marketing Automation plan definition (entry condition or custom listener).
So we get to a point where a custom condition has to be created.
Implementation is fairly easy and this post is not intended to go into implementation details. You can find the source code and configuration files on GitHub. Once you get to the code you will find two sets of conditions:
Be sure to follow Sitecore documentation for rules definition and deployment.