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
- Anonymous user is coming in the website and interact with the page and trigger some
goals
- Anonymous has a contact ID
- 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.
- My facets are updated for an existing contact
- After 20 mins, when the session expires, it is creating anonymous contact as well in
xDB
and also savingInteraction
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()));