I'm using 9.1.1, and at the moment all of the contacts I have in experience profile are coming back as unknown. For our system, you have to log in to use anything beyond the homepage, and as part of the login process I have the following script to set up a contact card for the user; this is called each time. My main layout has the VisitorIdentification call as well.
private static void TrackUserInSitecore(UserProfile profile) {
if (!Tracker.IsActive || Tracker.Current.Contact == null) {
return;
}
try {
Contact trackContact = Tracker.Current.Contact;
IContactPersonalInfo personalFacet = trackContact.GetFacet<IContactPersonalInfo>("Personal");
personalFacet.FirstName = profile.GetCustomProperty(Constants.UserProfile.FirstName);
personalFacet.MiddleName = profile.GetCustomProperty(Constants.UserProfile.MiddleInitial);
personalFacet.Surname = profile.GetCustomProperty(Constants.UserProfile.LastName);
personalFacet.Nickname = profile.GetCustomProperty(Constants.UserProfile.Alias);
personalFacet.JobTitle = profile.GetCustomProperty(Constants.UserProfile.Role);
IContactEmailAddresses emailFacet = trackContact.GetFacet<IContactEmailAddresses>("Emails");
IEmailAddress emailAddress;
const string type = "Primary";
if (!emailFacet.Entries.Contains(type)) {
emailAddress = emailFacet.Entries.Create(type);
emailAddress.SmtpAddress = profile.Email;
emailFacet.Preferred = type;
} else {
emailAddress = emailFacet.Entries[type];
emailAddress.SmtpAddress = profile.Email;
}
IContactPhoneNumbers phoneFacet = trackContact.GetFacet<IContactPhoneNumbers>("Phone Numbers");
IPhoneNumber phoneNumber;
if (!phoneFacet.Entries.Contains(type)) {
phoneNumber = phoneFacet.Entries.Create(type);
phoneNumber.Number = profile.GetCustomProperty(Constants.UserProfile.PhoneNumber);
phoneFacet.Preferred = type;
} else {
phoneNumber = phoneFacet.Entries[type];
phoneNumber.Number = profile.GetCustomProperty(Constants.UserProfile.PhoneNumber);
}
} catch (Exception ex) {
_logRepository.Error($"Error setting contact card for {profile.UserName}", ex);
}
}
Is this a scenario where perhaps I'm not calling a "commit" to lock this data in place so it appears in experience profile, or I'm going overkill in putting this data into a contact card "fresh" each time? My logout process does a Session.Abandon so I can quickly check if the data is processed.
(In writing this question out I did notice this question/answer as well: Timeline always showing contact as unknown in Sitecore 9. I'm going to look at that in addition, but I'd like to make sure my basic contact tracking concept is correct as well.)