I was always curious to know about how Amazon shows relevant products, how YouTube recommends new videos and Netflix/Prime next series/movies.
Well the below post is the Sitecore version of it. It’s about how we can achieve a similar personalized user experience in a Sitecore based site.
In this post, I am gonna discuss about a site’s User, Visitor and a Contact. What are they? How do they differ and How/Where/When to create/identify a contact, Contact tracking.
Visitor – A Visitor is some one who visits our website. They may be redirected to our site via a search engine or any online/offline promo/campaigns. They can be anyone who has access to our site. Bottom line is, to us they are anonymous. We don’t have any information about them. By information I mean their name, email or number etc.,
User – User is some one who has already registered to our site. They have a membership with our site. They have a login credentials, they can login to our site and avail services. We also have their name, email or number that can be used to identify them among our visitors/users.
Contact – Contact is an entity that holds information about visitor’s/user’s interaction with our site, like the pages they have visited, events/goals they have triggered. The time they have spent in each page, their total interaction duration and many more. Basically the marketing data that can be associated with a user/visitor.
Contacts can be of two types. Anonymous and Known Contacts.
In Sitecore, every time a visitor visits you site, a analytics cookie (sc_analytics_global_cookie) is created and it is associated with the current visitor. This cookie has a contact id – GUID. Sitecore captures all the interaction data (mentioned above) of the visitor during the current visit and stores it in the DB.

(The Contact ID in the cookie value is associated with a identifier and a device profile ID and stored in DB)
If the same visitor visits our site with the same browser again. Sitecore identifies the visitor using the cookie and remembers the visitor’s previous interaction and also associates the interaction data captured during the current visit along with the data from the previous visit.
Now, if the visitor clear the cookie, the cookie value is lost. Even though the visitor has visited our site before due to the lock of cookie, he will identified as a new visitor and a new GUID will be associated with the visitor. Basically, we won’t be able to link his previous interaction data with his current visit.
Well, this is the case for all the public sites without any user membership.
But, for sites that has membership i.e., Login it can be different. Say once the user logs in, an identifier – username or emailid or contact number can be used to identify the user and capture their interaction data. Even if they visit the site again, using this identifier we can associate their current collected interaction data with their previously collected data.
Sitecore handles the collection of interaction data using xConnect components. xConnect is a service layer in between the xDB and any client that wants to read, write or search contact and interaction data.
XConnect can be consumed via Sitecore Context and also from any other trusted client.
Anonymous Contacts have no registered identifiers. Known Contacts have registered identifiers.(username, emailid or number )
Now, moving on to Creating and Identifying a contact.
In all our membership sites, we have a sign up module, allowing user to create accounts in our site to login and avail services. We should create contacts that can be associated with the user along with an identifier say emailid or username. The Identifier is a unique attribute associated with a contact. No two contacts can have same identifier. In fact Sitecore throws exception if your try to create two contacts with same identifier.
Facet is an information about a contact. It’s like an attribute to a class. First Name, Last Name, Email-ID and phone number are some of the common examples of facet to a contact. In the example below Name, Job Title , Email Address, Phone Number and Contact Address facets are filled for the following contact.
Contact contact = new Contact(new ContactIdentifier(source, Identifier, IdentifierType));


Similarly, we have login module to authenticate our users. Once, the login authentication is done, we can identify the current user to a known contact using the unique identifier. So that the interaction data captured can be associated with previous data.
var identificationManager = Sitecore.DependencyInjection.ServiceLocator.ServiceProvider.GetRequiredService();
Sitecore.Analytics.Tracking.Identification.IdentificationResult result = identificationManager.IdentifyAs(new Sitecore.Analytics.Tracking.Identification.KnownContactIdentifier(“Local”, “realmadrid”));
Sitecore.Analytics.Tracker.Current.StartTracking();

In the screenshots, for illustration, I have created a helper method to create contacts and simple controller rendering that identifies the current user to a known contact (previously created one). Basically this setup is for me to collect some marketing data that I can use for exploring other modules of Sitecore like Marketing Automation or EXM etc.






Now, connecting the intro in this post, Amazon, YouTube, Netflix or Prime. Remember in my previous post, I would have written about Profiling the contents, creating profile cards and pattern cards. The collected interaction data combined with content profiling, we can provide personalized customer experience.

For Eg. Based on visits, it’s profiled currently as some one who likes travelling to Cities and Cultural places.
For more details,
https://doc.sitecore.com/developers/91/sitecore-experience-platform/en/contacts.html
https://doc.sitecore.com/developers/91/sitecore-experience-platform/en/tracking-contacts.html
https://doc.sitecore.com/developers/91/sitecore-experience-platform/en/identifying-contacts.html