I'm trying to figure out how the DeviceDetection api can be used to detect Bots visiting the website. Sitecore version: 9.0.2
When specific pages get visit, I want to log if it is a bot or not.
var deviceInfo = DeviceDetectionManager.GetDeviceInformation(HttpContext.Current.Request.UserAgent); return deviceInfo != null ? deviceInfo.DeviceType.ToString() : "";
But after testing, it seems that certain UserAgents always return the DeviceType
Computer. Example UserAgent:
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +http://www.google.com/bot.html) Safari/537.36
While I expect the DeviceType to be
Bot in this case. Which it clearly is, it even says Googlebot.
So I started to deassemble the Sitecore.DeviceDetection.CES.dll
- First off all, the documentation specifies to use
DeviceInformation.IsBotbecause the enum value
But... the DeviceDetection does not even contain a property IsBot.
- I looked at the 51Degrees implementation that should set the DeviceType. This is in
But... there is no code that ever sets the DeviceType to Bot.
So my question is, how can I check for a Bot using the DeviceDetection api?