For all of my analytics development, I have to know what Sitecore is seeing about my user/session. This includes everything from goals, events, profiles, patterns, pages, geo, marketing automation and now xConnect facets. And all of these have current session and past (Behavioral Cache) version.

Way back in 8.2 I wrote a little json app that would tell me what my current session is doing. I have kept it up to date and now I have released my 9.1 version of it.

An important note for this release is the Sitecore facets. The way it works in Sitecore is that it you get back the facets you request via the ContactExpandOptions. What I did for this, is I reach into the xConnect server configuration and get back all the KnownModels from the service. These are all the facet models that xConnect knows about. I then pass that into the ContactExpandOptions to get back all the facets and serialize them.

public IEnumerable<XdbModel> GetFacetModels()
   using (var client = _contactIdentificationRepository.CreateContext())
      var configuration = (XConnectClientConfiguration)client.Configuration;

      return configuration.ConfigurationClient.KnownModels;

The json includes, but not limited to:

  • Identifiers
  • Contact status
  • Visited pages
  • Interaction details
  • Goals in current session
  • Goals in the past visits
  • Events in current session
  • Events in the past visits
  • xConnect Facets with values
  • Current profile/patterns identified
  • Past profile/patterns identified

Here is what the json output looks like.