It is not necessarily a bad practice or cause any issues. If you are using the Sitecore Personalization rules, you can target the profiles which are associated to the user. If no profile is found, this means the user is not in a particular segment.
Now, in order for you to tag the user with a profile, you will need to add a pipeline in the <startTracking>
. This pipeline will have the task to boost the user profile to the default one, let's say Unknown Category
.
Below is a code snippet that I was using on Sitecore 8 to boost the user pattern of the user.
public static void BoostUserPattern(Session userSession, string patternName)
{
var patternCards =
Context.Database.GetItem("Path or Id of required Profile pattern card container").Children;
var patternCard = patternName.ToLower().Equals("register")
? patternCards.FirstOrDefault(w => w.Name.ToLower().Equals("register"))
: patternCards.FirstOrDefault(w => w.Name.ToLower().Equals("unknown"));
if (patternCard == null)
{
return;
}
var profile = Tracker.Current.Interaction.Profiles[patternCard.Parent.Parent.Name];
BoostUserPattern(userSession, patternCard, profile);
}
public static void BoostUserPattern(Session session, Item patternCard, Profile profile)
{
if (patternCard != null && !patternCard.Name.Equals(profile.PatternLabel))
{
Sitecore.Data.Fields.XmlField xmlData = patternCard.Fields["Pattern"];
XmlDocument xmlDoc = xmlData.Xml;
XmlNodeList parentNode = xmlDoc.GetElementsByTagName("key");
var scores = new Dictionary<string, float>();
foreach (XmlNode childrenNode in parentNode)
{
if (childrenNode.Attributes != null)
{
scores.Add(childrenNode.Attributes["name"].Value, 0);
}
}
// Boost profile key(s) here
scores[patternCard.Name] = 5;
profile.Score(scores);
profile.PatternId = patternCard.ID.ToGuid();
profile.PatternLabel = patternCard.Name;
// Update the historical data for the user
UpdateBehaviorProfile(session);
}
}
private static void UpdateBehaviorProfile(Session session)
{
var profileConverterBase = BehaviorProfileConverterBase.Create();
if (session?.Contact == null || Tracker.Current.Interaction == null)
{
return;
}
session.Contact.BehaviorProfiles.RemoveAll();
foreach (var profileName in session.Interaction.Profiles.GetProfileNames())
{
var profile = session.Interaction.Profiles[profileName];
if (!IgnoreInteractionProfile(profile))
{
var matchedBehaviorProfile = profileConverterBase.Convert(profile);
session.Contact.BehaviorProfiles.Add(matchedBehaviorProfile.Id, matchedBehaviorProfile);
}
}
}
private static bool IgnoreInteractionProfile(Profile profile)
{
Assert.ArgumentNotNull(profile, "profile");
return false;
}
EDIT
As you would see, the method UpdateBehaviorProfile
will add the profile to the historic data. In other words, if a user has no profile, going through the boosting mechanism will push the profile up to the historical data.