Insights

Sitecore Analytics Not Working (Could not update device detection database Error)

Device Detection and Analytics Work And Fail Together

Somewhere along the line, Sitecore decided to include device detection as part of the vanilla Sitecore offering instead of a paid add-on service. This transition did not come without issues.

The Tell

Problems related to device detection and Sitecore Analytics appear to occur in instances of Sitecore XP 9.0 rev. 171002 (Initial Release) and SItecore XP 9.0 rev. 171219 (Update-1). Most developers spotting this issue for the first time will see the following errors in the Sitecore log.


WARN  Authentication on CES Discovery service failed.
Exception: System.Net.WebException
Message: The remote server returned an error: (403) Forbidden.
Source: System
   at System.Net.HttpWebRequest.GetResponse()
   at Sitecore.CES.Client.WebClient.<>c__DisplayClass6_0.b__0()
   at Sitecore.CES.Client.WebClient.Execute[T](Func`1 action, String requestUri)
   at Sitecore.CES.Client.ResourceConnector`1.Request(String endpoint, Object[] parameters)
   at Sitecore.CES.Discovery.EndpointSource.GetEndpoint(String serviceName)

ERROR Could not update device detection database
Exception: System.ArgumentNullException
Message: Null ids are not allowed.
Parameter name: endpointUri
Source: Sitecore.Kernel
   at Sitecore.Diagnostics.Assert.ArgumentNotNullOrEmpty(String argument, String argumentName)
   at Sitecore.CES.Client.WebClient.DownloadBinaryContent(String endpointUri, String resourcePath, DownladBinaryContentParameters parameters)
   at Sitecore.CES.DeviceDetection.Providers.FiftyOneDegrees.FiftyOneDeviceDetectionClient.GetNewerVersion()
   at Sitecore.CES.DeviceDetection.Providers.FiftyOneDegrees.FiftyOneDeviceDetectionClient.DoUpdate(String serviceName, String& newDatabasePath, String& newDatabaseVersion)
   at Sitecore.CES.DeviceDetection.Providers.DeviceDetectionClient.Update()

You may also see JavaScript console errors when viewing the Sitecore Launchpad or Experience Analytics:

Or similar.

The Fix

The simplest solution is to simply disable device detection via a Sitecore config patch or spot replacement in the default config file (not recommended). However, this has the potential to produce issues if your site is making use of device detection and can also cause suspect analytics data to come through which can be jarring for clients relying on the analytics data.

Sitecore has had an official hotfix since February 2018, meaning that many instances are still plagued with this issue.

https://kb.sitecore.net/articles/828414

The hotfix is an updated version of Sitecore.CES.dll.

On single instance installs, this hotfix will likely fix your issue. Simply install the package via the Package Installer GUI. Make sure you're installing the right package. This hotfix in particular is a .zip file containing a readme file and another .zip file. If you install the top level zip, you will be given the impression that the fix was installed successfully, when in reality nothing has occurred. When you proceed through the package install process the package should see the package information fields populated:



However, more work is required for more complex instances.

Azure App Services / PaaS / ARM Templates / Sitecore Managed Cloud

More complex instances of Sitecore will include various App Services. Installing the hotfix package via the GUI is not enough.

Replace the Sitecore.CES.dll in all App Services that contain the file. The following are a good starting point.

  • APP-SERVICE-NAME-rep
  • APP-SERVICE-NAME-prc
  • APP-SERVICE-NAME-cm
  • APP-SERVICE-NAME-cd

One easy way to update these files on Azure is to use the App Service Editor. An easy way to navigate to the file system and directly to the problematic DLL is via your web browser using the following URL:

https://APP-SERVICE-NAME.scm.azurewebsites.net/dev/wwwroot/bin/Sitecore.CES.dll

From there you will easily be able to right click the bin folder and upload and replace the fixed DLL in one swift action.

Log In, Log Out (KEY!)

After applying the fix in all locations, make sure to log out of Sitecore and back in again. We've witnessed several occasions where this step was missed, giving the developer the impression that the hotfix did not work.

Conclusion

Once the fix has been properly applied, none of your Sitecore logs will show device detection errors. Additionaly, all Sitecore Analytics should be working as expected. If this is not the case, ensure that you've completed all of the steps.

Good luck out there,

Marcel

👋 Hey Sitecore Enthusiasts!

Sign up to our bi-weekly newsletter for a bite-sized curation of valuable insight from the Sitecore community.

What’s in it for you?

  • Stay up-to-date with the latest Sitecore news
  • New to Sitecore? Learn tips and tricks to help you navigate this powerful tool
  • Sitecore pro? Expand your skill set and discover troubleshooting tips
  • Browse open careers and opportunities
  • Get a chance to be featured in upcoming editions
  • Learn our secret handshake
  • And more!
Sitecore Snack a newsletter by Fishtank Consulting