LibrarySites.Banner

Using Custom Contact Data Part 3 - Rules

Starting with Sitecore 7.5 an individual visitor is represented using a contact. Information that is collected about the contact is stored in contact facets. This part 3 in a 3-part series that explores how data stored in contact facets can be used throughout the Sitecore Experience Platform.

In this post I will cover how data stored in contact facets can be used when configuring personalization, engagement plans and other components that use the Sitecore rules engine.

Prerequisites

In my previous post I covered how to get custom contact data into xDB using contact facets. This post assumes you have read that post.

Contact Data and Conditions

Creating custom conditions for Sitecore is a pretty basic task for a developer. In my post introducing contact facets I described the code needed to read data from contact facets. That logic can be put into a custom condition. 

There are plenty of blog posts and documentation that explains how you create custom conditions, so I wanted to create something different.  I wanted to make it possible to use a single condition to check any value on any facet.

The implementation turned out to be too complicated to explain in a blog post. I actually started writing it and decided to stop after about 10 pages. 

Instead, I packaged up my work into a couple of modules, threw the source code up on GitHub (here and here), and recorded a couple of videos that demonstrate how to use it all. 

The first video demonstrates the Adaptive Rules module. This provides the ability to have a single condition that can handle any contact facet data.

The second video demonstrates the Contact Utilities module. This provides a custom condition based on the Adaptive Rules module that implements the ability to have a single condition that can handle any contact facet data.

There's a lot of stuff in these two modules. I'm happy to cover some of the details in separate posts, but I need to know what you're interested in. So let me know in the comments.

  • Can we make this works for the Segment Builder in the List Manager?

  • I implemented your solution and enabled it on List Manager for segmentation. It seems to provide exactly what I needed in the UI. It gives me the ability to query any field on any facet. Perfect! But, it doesn’t return the correct results. So it’s not processing the query to mongodb properly. Ideas on how to fix/debug this?   More details:  I’ve tried it on all 3 of my servers and they all produce a different # of results. It doesn’t seem to matter what type of filter I put in place, it always returns the same number of contacts but the results are very wrong. (The number of contacts is also different on each server). My dev server always says 5 contacts returned (out of 8 total in the mongodb analytics db / contacts collection). The QA server always says 6411 (out of 147250 mongodb contacts). The production server always says 19010 (out of 147250 mongodb contacts). i.e. If I’m asking for everyone named Mike or everyone at XYZ company or everyone with Shirtsize = Medium, the wrong (but same) number are reported back. Doesn't matter if it's a custom field I added in a custom facet or a standard field such as Firstname in the Personal facet. No matter how complex or simple the rule filter, it's always the same results. Note that the out of the box Segment Builder conditions do work properly, those filter queries to mongodb execute correctly. All mongodb's are local on the server.  Help!! Thank you!

  • I believe the rules in List Manger use the contents of the sitecore_analytics_index (powered by Lucene), whereas the rules used elsewhere (i.e. personalization) use the facet data loaded from Mongo and stored in a user's browsing session. For this reason, rules intended for use in one place will not work in the other.