Kyle Kingsbury A Sitecore web development blog!

Reaching the max pages viewed threshold for an xDb Session


In my current project, I came across an odd issue for a component that was developed using interactions captured by xDb where xDb would completely stop tracking after what appeared to be at arbitrary intervals. To some testers, xDb would stop tracking after 9 page views, others it was 10-12 page views. What I didn’t know at the time was that Sitecore xDb comes configured with a setting, MaxPageIndexThreshold (set to 50), on the SetDummySession processor within the ensureSessionContext pipeline that ultimately will stop tracking after a threshold is met. Who knew! Luckily for me, Sitecore was logging a very informative error message when this threshold had been hit:

Session with Id [session id] has reached the max page threshold of 50. If you see this message regularly, you should increase configuration parameter MaxPageIndexThreshold to avoid loss of valid data

Understanding the error was straightforward, xDb had stopped tracking all interactions after it hit the MaxPageIndexThreshold of 50. But how was the system reaching this limit only after 9-12 reported page views? After a brief look into Sitecore xProfile and MongoDb, it was pretty obvious, we had set up tracking on all of our API requests. So for every page view, we would potentially be triggering 3-6 additional page views.

Resolving the issue was a simple change in configuration, however, removing all of our AJAX requests from being tracked was a little trickier. Luckily, EPAM Systems very own Pavel Veller had written a post a few years back about how to track AJAX requests as a page event for the previous page. Using a modified version of Pavel’s code, I was able to remove unnecessary tracking of AJAX requests as page views. With the change in configuration and removing of unnecessary tracking, the issue was non-existent.

While the issue was self-inflicted, I definitely learned my lesson. On my current and future projects, I will only be tracking AJAX requests as page events and only for AJAX requests that were triggered by the visitor. 

Add comment

Kyle Kingsbury A Sitecore web development blog!

Recent Posts