Extending xDB by creating a custom contact facet
In xDB, you can store custom contact information using System
facets such as Tags
and Extensions
. However, to store complex information such as dictionaries or collections, you can extend the Contact
with your custom facet. In this recipe, you will learn how to store shopping cart information to the Contacts
collection in xDB.
Getting ready
For this recipe, you should create product pages with an Add to cart button on it.
How to do it…
We will first create a Contract
to define the structure of elements of the facet:
- In the
SitecoreCookbook
project, create anIShoppingCartRecord
interface in theModel
subfolder in theAnalytics
folder that extends theIElement
andIValidatable
interfaces as follows:
Get Sitecore Cookbook for Developers now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.