When debugging Sitecore xDB issues, it is a pain that data is not written to MongoDB directly, but you have to wait for your session to end.
The legend said that you could either set the session timeout to 1 minute, or call Session.Abandon() to write to MongoDB. None of this have ever worked for me, until my colleague Lasse Pedersen found the final, bullet-proof way of having the xDB session data written to MongoDB.
Create a page with the following contents, and call it when you wish to flush data from xDB to MongoDB:
Sitecore.Analytics.Tracker.Current.EndTracking(); HttpContext.Current.Session.Abandon();
We will all pray to the debugging gods that this fix will work in every scenario.
When testing something similar I found sometimes Sitecore would abort the commitSession pipeline due to either thinking I was a robot or having no pages (IgnoreVisitsWithoutPages).
I’ve not had issues with the minute timeout but would happily speed up the wait with the example above :)
LikeLike
Interestingly EndVisit() was temperamental for me, but Session.Abandon() worked :)
With regards to robots, update the setting to false to not detect:
LikeLike
Hello Brian,
We use FlushContactToXdb2 and seems to be flawless so far.
public Contact Flush()
{
return this.contactManager?.FlushContactToXdb2(this.Contact);
}
Let me know if this works out the same =)
LikeLike
Pingback: Sitecore MongoDB – What do we know about a contact? | Brian Pedersen's Sitecore and .NET Blog
You are the man Brian!
LikeLike