In a Sitecore 8.1 Update 3, we have configured the mongodb for shared session state into "Session" collection, and analytics is configured separately into its own collection as well. The code is configured to preserve obtained location data into a custom facet. That data is recalled between browser sessions to allow the site visitor (anonymously) to recall its location settings. I have confirmed that rebooting iis site, the SC_Analytics_Global_Cookie value is preserved, and the facet is deserialized and location data is accessible. However, after about 20min or so, of inactivity (closing browser) the value of the cookie still stays the same, but I no longer see the location data.
Is there an expiration set up for "unidentified" contact within Sitecore?
Here is the code i use to recall the Location data. IGeoTracker is a child interface of the IFacet.
ITracker current = Tracker.Current;
if (((current == null) || !current.IsActive) || (current.Contact == null))
{
SetLocationUnknown();
}
else
{
IGeoTracker facet = current.Contact.GetFacet<IGeoTracker>(this._geoTrackerFacetName);
if (!String.IsNullOrEmpty(facet.FormatedAddress))
{
string formatedAddress = facet.FormatedAddress;
SetLocationKnown(formatedAddress);
...
}
else
{
SetLocationUnknown();
}
}
Update
I have been doing a bit of reverse engineering with dotPeek tool, and deduced that the ShareSessionStateManger is designed to be 1 minute longer than a private session state timeout which is defined in the web config. Either way the shared session state store is not designed to persist the contact data indefinitely.
Per further research, the contact data must make it back into the Analytics database. That's when I validated that Contact is not being written back into the Analytics Collection. The default Sitecore configuration actually uses a stub contact repository class which prevents the persistence of analytics data. To enable that, we must deploy the configuration in Sitecore.Analytics.Tracking.Database.config
<sitecore>
<pipelines>
<commitSession>
<processor type="Sitecore.Analytics.Pipelines.CommitSession.CheckPreconditions, Sitecore.Analytics" />
<processor type="Sitecore.Analytics.Pipelines.CommitSession.UpdateGeoIpData, Sitecore.Analytics" />
<processor type="Sitecore.Analytics.Pipelines.CommitSession.EnsureClassification, Sitecore.Analytics" />
<processor type="Sitecore.Analytics.Pipelines.CommitSession.UpdateContactBehaviorProfiles, Sitecore.Analytics" />
<processor type="Sitecore.Analytics.Pipelines.CommitSession.Robots, Sitecore.Analytics" />
<processor type="Sitecore.Analytics.Pipelines.CommitSession.IgnoreVisitsWithoutPages, Sitecore.Analytics" />
<processor type="Sitecore.Analytics.Pipelines.CommitSession.UpdateContactSaveMode, Sitecore.Analytics" />
<processor type="Sitecore.Analytics.Pipelines.CommitSession.SubmitSession, Sitecore.Analytics" >
<SessionContextManager ref="tracking/sessionContextManager" />
</processor>
<processor type="Sitecore.Analytics.Pipelines.CommitSession.ProcessSubscriptions, Sitecore.Analytics"/>
<processor type="Sitecore.Analytics.Pipelines.CommitSession.ReleaseSharedSession, Sitecore.Analytics" runIfAborted="true"/>
</commitSession>
<postSessionEnd>
<processor type="Sitecore.Analytics.Pipelines.PostSessionEnd.CommitSession, Sitecore.Analytics" />
</postSessionEnd>
<submitSessionContext>
<processor type="Sitecore.Analytics.Pipelines.SubmitSessionContext.SaveDevice, Sitecore.Analytics" patch:before="*" />
<processor type="Sitecore.Analytics.Pipelines.SubmitSessionContext.SaveClassificationsMap, Sitecore.Analytics" patch:after="*[1]" />
<processor type="Sitecore.Analytics.Pipelines.SubmitSessionContext.SaveVisit, Sitecore.Analytics" patch:after="*[2]" />
<processor type="Sitecore.Analytics.Pipelines.SubmitSessionContext.RenumberInteractions, Sitecore.Analytics" patch:after="processor[@type='Sitecore.Analytics.Pipelines.SubmitSessionContext.SaveVisit, Sitecore.Analytics']" />
<processor type="Sitecore.Analytics.Pipelines.SubmitSessionContext.UpdateKeyBehaviorCache, Sitecore.Analytics" patch:after="processor[@type='Sitecore.Analytics.Pipelines.SubmitSessionContext.RenumberVisitIndexes, Sitecore.Analytics']" >
<ContactManager ref="tracking/contactManager" />
</processor>
</submitSessionContext>
</pipelines>
<submitQueue>
<backgroundService type="Sitecore.Analytics.SubmitQueueService, Sitecore.Analytics">
<!-- Service wakeup interval in seconds. -->
<Interval>60</Interval>
</backgroundService>
</submitQueue>
<tracking>
<contactManager type="Sitecore.Analytics.Tracking.ContactManager, Sitecore.Analytics" singleInstance="true">
<param desc="sharedSessionStateManager" ref="tracking/sharedSessionState/manager" />
<param desc="contactRepository">
<patch:delete />
</param>
</contactManager>
</tracking>
</sitecore>