Running Sitecore 8 and your analytics database doesn't seem to be collecting data? We've assembled some helpful tips.
This post pertains to on-premise xDB deployments; Sitecore xDB Cloud Edition has a separate analytics configuration, although many of these steps would apply there as well.
You’ve got a brand-new installation of Sitecore 8 up and running and you’ve followed the installation instructions and wrestled Mongo to the ground.
But sadly, your analytics reports remain empty – they’re not recording the interactions on your website. What gives?
We’ve spent a fair amount of time troubleshooting this and helping our clients get rolling. Below are helpful steps to try:
1. Let’s start with the (not-so) obvious: is Mongo running? Particularly in development environments, it can be easy to forget if you did not configure Mongo as a service. Ensure your Mongo is running and use a tool such as MongoVUE to monitor raw traffic in real-time.
2. Verify your connection strings. Check that your /App_Config/ConnectionStrings.config file has been correctly updated to reference your Mongo instance and reporting database instance, and that they can be accessed from your Sitecore instance. (Scaled xDB configurations are an entire other blog post; get started here).
3. Make your life easier and shorten your session time while troubleshooting, so interaction data is flushed to Mongo in short order. By default, the session state timeout is set to 20 minutes. This is found in the web.config under <sessionState timeout="20"/>. (NB: session state mode will vary depending on your scaling configuration).
4. Ensure your main layout includes the Visitor Identification control. This is mandatory for tracking on each published page.
- For WebForms projects, include the <sc:VisitorIdentification runat=”server”> control included in the <head> section of your layout ASPX file.
- For MVC projects, include @Html.Sitecore().VisitorIdentification() in the <head> section of your layout CSHTML file. You will also need to reference Sitecore.MVC.Analytics in your project.
5. Ensure Analytics is enabled. Check the <setting name="Analytics.Enabled" value="true" /> in your /App_Config/Include/Sitecore.Analytics.config file.
6. Check your most recent log file for errors on your CD nodes. This file can be found in /data/logs and will be named log.<timestamp>.txt. Errors related to analytics tracking can be commonly spotted as:
- Mongo is not running
- The Analytics.Tracker object cannot be initialized due to an error in your configuration or an older patch file that may no longer be compatible
- A connectivity error across the network to a database or service
7. Be careful if you are calling to the Sitecore WebAPI. We confirmed with Sitecore Support that the expected behaviour is that requests to WebAPI web services are recorded in the xDB as interactions and pageviews, which could skew your analytics reports incorrectly.
The recommended fix is to either call an additional method that will cancel the analytics logic for the request:
Or to configure a custom site in the “sites” config specifically to cover the web service requests and disable analytics for that site.
<site name="customAPI" virtualFolder="/api/custom" physicalFolder="/api/custom" ... enableAnalytics="false" />
8. Take a moment to check the Submit Queue for records or errors, where xDB data is stored if it cannot be submitted to xDB. This file can be found in /data/Submit Queue.
9. Double-check against the xDB troubleshooting tips provided in this Sitecore KnowledgeBase article, particularly regarding Global.asax
10. Finally, you should carefully check your infrastructure and configuration are setup properly. The session state configuration is particularly important.