Accessing facets in session
When a visitor returns to your site, a configurable list of facets are loaded into session from xConnect.
You can edit facets that are loaded into session, but they are not automatically saved to xConnect on session end. You must use the xConnect Client API to update facets.
Access the IXConnectFacets class in session
The IXConnectFacets tracker facet inherits Sitecore.Analytics.Model.Framework.IFacet and contains a dictionary of xConnect facets that inherit Sitecore.XConnect.Facet. Configuration determines which facets are loaded into the facets dictionary. The following example demonstrates how to access the PersonalInformation facet, which is available by default:
Access legacy facet classes in session
In addition to the IXConnectFacets facet, a number of legacy facet classes are populated at the start of the session. This means that some facet data is available in two locations. The following table lists all legacy facets that are loaded into session and their corresponding xConnect facet:
|
Legacy Facet |
Matching entry in |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The following example demonstrates how to access the legacy IContactPersonalInfo facet:
The following example demonstrates how to access the data represented by the IContactPersonalInfo facet via the newer IXConnectFacets facet:
Access the key behavior cache facet in session
The following example demonstrates how to access the key behavior cache:
Each key behavior cache entry has a DefinitionId property. Use the Marketing Operations API to retrieve definition items by ID.
Access the contact behavior profile facet in session
The following example demonstrates how to access the contact behavior profile:
Access automation plan enrollments in session
The following example demonstrates how to access a contact’s automation activities:
Each automation plan enrollment cache entry has a plan definition ID and an activity ID. Use the Automation Plan Definition manager to retrieve the plan definition item. Use the Activity Descriptor Locator API to retrieve activity descriptors by ID.