I am unable to create a contact in xDB in a scaled CM server with the below code, whereas the same code is working on the dev Server.

I believe Sitecore.Analytics.Tracker.Current.Session.IdentifyAs is not creating the contact and I am getting Object reference not set to an instance of an object error while setting the Personal Facet (because currentContact is null).


Sitecore.Analytics.Tracker.Current.Session.IdentifyAs(contactus.telephone, contactus.email);
var currentContact = client.Get<Contact>(new IdentifiedContactReference(contactus.telephone, contactus.email), new Sitecore.XConnect.ContactExpandOptions());

if(currentContact ==null)
    new Logger().Info("CreateContact : session  contact is null");

Getting Log entry "CreateContact : session contact is null" always in staged CM but not on dev.


Can you check what role is configured on web.config Stage CM server ? I am refering to this setting:

         Specify the roles that you want this server to perform. A server can perform one or more roles. Enter the roles in a comma separated list. The supported roles are:


    Default value: Standalone
    <add key="role:define" value="Standalone,Local" />

If is "ContentManagement" server is a normal behavior because Tracking is not working on CM server.

Can you check on Dev environment if you have Standalone role configured.

  • this is a normal behaviour. If you changed on Stage to Standalone will not crash. I suggest you to test analytics on CD servers not on CM. Jan 27 '20 at 14:10
  • 1
    Yes , It works . Marked your Answer as accepted
    – Shailesh
    Jan 27 '20 at 14:13

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.