1

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.

anonymous facets on db

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;
            }
        }
  • Is the anonymous contact saved? Also, can you save any of the built-in facets? – grg Jun 25 at 13:48
  • Yes the anonymous contact is saved. And the built-in PersonalInformation facet fields like first name and last name is also saved. – Bien Angelo Relucano Jun 25 at 14:07
  • Are you sure that your custom model json file is copied to XConnect? – grg Jun 25 at 15:00
  • 100% possible. Do it all the time. Can you post your facet saving code. That is more important than the getting code. – Chris Auer Jun 25 at 19:39
  • Of course, it is possible. It doesn't matter is your contact anonymous or known. Did you save contact changes with client.Submit()? Check log files for xconnect errors. – x3mxray Jun 26 at 6:56
5

Yes you can save custom facets for Anonymous contact as well.

I have written a blog for creating and save custom facets, please refer both the blogs and verify if you missed anything.

A method CurrentTracker.Session.IdentifyAs() in Sitecore.Analytics interface, it is used to make your contact from Unknown (Anonymous) to Known.

Let me know in case you need further help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.