Contact facets in the tracker

Version: 10.0
Important

Facets that are loaded into session can be edited but are not saved to xConnect on session end. You must use the xConnect Client API to update facets.

Facets are represented by the Sitecore.Analytics.Tracker.Current.Contact.Facets dictionary in the tracker and are loaded from xConnect into shared session state at the start of a session. The tracker does not lock contacts in session, and changes made to facets stored in Sitecore.Analytics.Tracker.Current.Contact.Facets are not saved on session end.

RequestResponse
// Legacy facet
// NOT SAVED ON SESSION END
var personalInfo = Sitecore.Analytics.Tracker.Current.Contact.GetFacet<IContactPersonalInfo>("Personal");
personalInfo.FirstName = "Myrtle";

// xConnect facet
// NOT SAVED ON SESSION END
var xConnectFacets = Sitecore.Analytics.Tracker.Current.Contact.GetFacet<IXConnectFacets>("XConnectFacets");
PersonalInformation personalInfoXConnect = xConnectFacets.Facets[PersonalInformation.DefaultFacetKey] as PersonalInformation;
personalInfoXConnect.FirstName = "Myrtle";

You must use the xConnect Client API to update contact facets. Submitting facets to xConnect immediately reduces the risk of  concurrency conflicts.

Facets are not automatically reloaded

Facets that have been cached in shared session state are not automatically reloaded when you use the xConnect Client API to submit changes to xConnect. You must manually update the cached facets or reload the contact from xConnect.

Important

Personalization relies on facets that have been cached in shared session state. Keep cached facets up to date in order to ensure that personalization is acting on the latest available data.

Do you have some feedback for us?

If you have suggestions for improving this article,