3

I have a Sitecore 9 form where a user submits a form and that contact will be saved in xDB. At the time of submitting I am checking in xDB is duplicate contact exist, on basis of First name, Last name, Email and Identifier source.

I am able to get duplicate contact using the below query:

    IAsyncQueryable<XConnect.Contact> query = client.Contacts
                .Where(c => c.Identifiers.Any(i => i.Source == "XYZ") &&
                       c.GetFacet<EmailAddressList>(EmailAddressList.DefaultFacetKey).PreferredEmail.SmtpAddress == emailID
                       && c.GetFacet<PersonalInformation>(PersonalInformation.DefaultFacetKey).FirstName == firstname
                && c.GetFacet<PersonalInformation>(PersonalInformation.DefaultFacetKey).LastName == lastname
                ).
                WithExpandOptions(new ContactExpandOptions( PersonalInformation.DefaultFacetKey, EmailAddressList.DefaultFacetKey));

Problem

  1. Anonymous user is coming in the website and interact with the page and trigger some goals
  2. Anonymous has a contact ID
  3. Then user visits my form which I am talking above, here they submit a form, now if a user is a duplicate I am updating facets.
  4. My facets are updated for an existing contact
  5. After 20 mins, when the session expires, it is creating anonymous contact as well in xDB and also saving Interaction for anonymous user.

I want anonymous user should not create in xDB and Interaction should save for existing contact only.

I have tried to use LoadContact method but still, it is not working

  manager.RemoveFromSession(CurrentTracker.Contact.ContactId);
   CurrentTracker.Session.Contact = manager.LoadContact(new Guid(existingContact.Id.ToString()));
0

I have resolved this issue using below points:

  1. Saved Anonymous contact first because Anonymous contact is still in Session
  2. Then get existing contact from the database and updated facets
  3. Merged existing contact into Anonymous contact using Merge API https://doc.sitecore.com/developers/90/sitecore-experience-platform/en/merge-contacts.html

Now I have Interaction as well as updated facets.

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.