How to Update xDB Contacts and Maintain your Sanity

There are 4 sets of Contact APIs in Sitecore xDB:

  • ContactRepository
  • ContactManager
  • SharedSessionStateManager
  • Tracker.Current.Contact

Each of them, apart from the ContactManager, has a clear purpose of working with a specific Contact storage. The ContactManager actually works with both the shared session and the Collection database via the underlying APIs, as you can see on the following diagram:

It’s relatively easy to update contact data via each of these API, provided that you know which one to use.

But what if you just want to update the contact, no matter where it’s currently located? Here’s a method I recently created that will help you:

And here’s how you can use it: