Hi guys,
I have a fairly simple question. I have created some custom facets
and tested them for known
Contacts and they work. But when I do the same regarding Anonymous
Contacts, I could not set the custom facets
being set on it.
I could not find anything in Sitecore documentation about it. Do you think it is even possible?
Here is my code for getting the contact for known
and anonymous
contact:
string contactId = CurrentTracker.Contact.ContactId.ToString("N");
var trackerIdentifier = IsAnonymous ? new IdentifiedContactReference(Constants.IdentifierSource, contactId)
: new IdentifiedContactReference(ContactSource, Identifier);
using (var client = SitecoreXConnectClientConfiguration.GetClient())
{
try
{
var facets = new string[]
{
PersonalInformation.DefaultFacetKey,
ServiceabilityFacet.DefaultFacetKey,
CustomerAttributesFacet.DefaultFacetKey
};
return client.Get<Contact>(trackerIdentifier, new ContactExpandOptions(facets));
}
catch (XdbExecutionException ex)
{
Log.Error($"Could not load contact by identifier {contactId}", ex, this);
return null;
}
}