Sitecore Users vs. Sitecore Contacts

What is a User?

USER is an authenticated account residing in the .NET Membership Database or other Federated Authentication service. Users are typically bound to a domain such as sitecore or extranet, or any other configured domain in Sitecore. A user typically has a Profile (ASP.NET Membership Profile) associated with the account that can store various values. The default structure of a username is in the format of domain/username.

What is a Contact?

CONTACT is a marketing term identifying a visitor to the website. A contact record and associated ID always exists for a visitor on the browser. There are primarily two types of Contacts: an Anonymous Contact and a Known Contact.

Contacts have Facets that provide a place to store Contact information, like Personal Information (name, surname, birthday, gender, etc), Contact Street Addresses, and Email Addresses. The Contact model can also be extended to store custom contact data.

Sitecore personalization can be used to read information from the contact facets for various personalization rules and List Segment Conditions can also be created to automatically create Contact Lists based off of facet information.

The difference between the two types of Contacts is that the visitor has provided some sort of identifying information that allows the site to programmatically identify a contact with some tangible and unique identifier. The most common types of identifiers are Email Addresses and Usernames.

Contacts are stored in Session during the visitor’s visit to the website via a cookie. One a visitor leaves the site, during the SessionEnd() process, the contact, any contact information, and interaction tracking information is moved from the session to the Mongo DB (or xConnect Collection). From there, the xDB Processing role of Sitecore will process the Mongo/xConnect Collection and move the information to the Sitecore Analytics index and the Reporting database.

The cookie persists past the visit so that the Contact, upon coming back, can continue to add visit information to the interactions. This cookie CAN be manually reset back to anonymous contact record by forcing both the visit to end and the Session to be abandoned.

Ending the Contact Visit / Resetting the Analytics Contact Cookie

Tracker.Current.EndVisit(true); HttpContext.Current.Session.Abandon();

The code above ends the visit and invalidates the cookie. Secondly, it forces the Session to end and immediately writes data to Mongo via the processEndSession().

Is there any relationship between a User and a Contact?

There is NO relationship in Sitecore, xDB, or xConnect that associates a User to a Contact. Any such relationship has to be done manually by use of identifiers and even then the application has to maintain that relationship. It is completely plausible that somehow a single logged in user might actually have two contact id’s or 1 contact id could somehow be used on two different users. It is up to the custom application to maintain any type of relationship.

Why is managing the contact cookie important?

In most use cases, we are always thinking of a visiting contact as the primary human using the computer to access the website. In most cases, this is fine. However, when you have an authenticated process, where a user can log into your site, it should be considered what happens when a user is using a public computer or sharing a computer with family/household members. I call this the Library Computer Problem.

The reason this problem exists is that of how the cookie is managed and separated from a logged in account. If Person A sits down at a Library computer and performs an action on your site which would identify that contact as a Known contact, the cookie is placed on that computer. Well, what happens if Person A gets up and Person B sits down on the same computer? Unless an action was performed that would tell the website that it’s a different user, any browsing will be done as Person A. Therefore, it’s important that we consider the purposefully ending the visit of a contact when a user logs out.

Have any Question or Comment?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discussion Topics