I am using Sitecore Experience Platform 9.0 rev. 180604 (9.0 Update-2) and my Experience profile does not show the Contacts that I have created, except for one Anonymous Contact that existed a month ago. The custom form submit action is supposed to get the details of the user (firstName, lastName, email) and identifies it as a Contact, but Experience Profile does not show it.
So for the steps I have tried (I actually have two variants of code in adding a Contact):
public virtual ContactIdentifier CreateContact(string email, PersonalInformation personalInfo)
{
var identifier = new ContactIdentifier(ContactSource, email, ContactIdentifierType.Known);
var identifiers = new ContactIdentifier[] { identifier };
try
{
if (CurrentTracker != null && CurrentTracker.IsActive && CurrentTracker.Session != null)
{
CurrentTracker.Session.IdentifyAs(ContactSource, email);
CurrentTracker.Contact.Tags.Set("isEmpty", "false");
}
using (var client = SitecoreXConnectClientConfiguration.GetClient())
{
var knownContact = new Contact(identifiers);
client.SetFacet(knownContact, PersonalInformation.DefaultFacetKey, personalInfo);
client.AddContact(knownContact);
client.Submit();
}
}
catch (XdbExecutionException ex)
{
Log.Error("Exception creating contact", ex, this);
}
return identifier;
}
and the second one which I took the snippet from Sitecore documentation:
public virtual bool CreateContact2(string email, PersonalInformation personalInfo)
{
if (CurrentTracker.Contact.IsNew)
{
var manager = Factory.CreateObject("tracking/contactManager", true) as ContactManager;
if (manager != null)
{
CurrentTracker.Contact.ContactSaveMode = ContactSaveMode.AlwaysSave;
manager.SaveContactToCollectionDb(CurrentTracker.Contact);
var trackerIdentifier = new IdentifiedContactReference(Sitecore.Analytics.XConnect.DataAccess.Constants.IdentifierSource,
CurrentTracker.Contact.ContactId.ToString("N"));
using (XConnectClient client = SitecoreXConnectClientConfiguration.GetClient())
{
try
{
var contact = client.Get(trackerIdentifier, new ContactExpandOptions());
if (contact != null)
{
client.SetFacet(contact, PersonalInformation.DefaultFacetKey, personalInfo);
client.Submit();
manager.RemoveFromSession(CurrentTracker.Contact.ContactId);
CurrentTracker.Session.Contact = manager.LoadContact(CurrentTracker.Contact.ContactId);
}
}
catch (XdbExecutionException ex)
{
Log.Error("Error in creating Contact.", ex, this);
return false;
}
}
}
}
return true;
}
Both of them ran successfully. And I can see my Contacts being created in my SQL Server (Xdb.Collection.shard0 and shard1) ContactFacets table:
Additional details:
- I have enabled my PII and Anonymous indexing
- I also ran the XConnectSearchIndexer -rr to rebuild my Reporting Database
And also disabled my Robot Detection from here
And my xConnect services are running, no problem
Am I missing something here?
P.S. I am testing my form via the Experience Editor > Preview mode of the page, does this have an effect?