Saturday, March 11, 2017

Sitecore custom contact facets with data access and display in Experience Profiles

In Sitecore, a contact is a person who interacts with a given organization. These contacts and all of the information collected about them is stored in the Experience Database (xDb) and can be viewed via the Experience Profiles section of Sitecore. By default a large amount of data is collected about the user's interactions with an organization across all devices and mediums (including print and email).

Sitecore Experience Profile view of a contact

The scope of this post series is the concept of creating a custom contact facet (which means the ability to store custom data against a contact). The next step is the ability to access this data (read/write) via code. Finally add a custom tab to the Experience Profile to allow users to view this custom data for any given contact. Then a look at how merging contacts works, when custom data is in play and how to personalize based on the data iteself.

Table of contents

  1. Part One: Creating a custom contact facet
  2. Part Two: Custom contact facet data access
  3. Part Three: Adding contact facet to Experience Profiles
  4. Part Four: Handling custom facets when merging contacts
  5. Part Five: Personalization rules for contact facets
This series has been developed on Sitecore version 8.2, and there will be minor differences from earlier versions. Take for example the accordion control which has been renamed to an... Advanced Expander!


Apart from the standard Sitecore instance (including MongoDB), along with Visual Studio. The only other requirement for following this series is Sitecore Rocks (either the Visual Studio plugin or stand-alone version). Sitecore Rocks is required for adding the contact facet to Experience Profiles - as this cannot be done via the standard web interface.

The scenario

To keep it simple, only 3 fields are going to be stored in the custom contact facet. The facet will be named CustomData.
  1. CRM ID - string
  2. Active Customer - boolean
  3. Product Purchases - List of custom object
    1. Product ID - string
    2. Purchase Date - datetime
These fields aren't chosen as they related well to real world examples, but more to showcase the various types of data that can be stored inside a contact facet.

The source code

The full source code for this series is available on GitHub, which includes Sitecore package for the items created. There is a test page for setting the facet data and another to abandon the session (pushes the data through to MongoDB and ultimately experience profile viewer faster).

No comments:

Post a Comment