The release of Sitecore 8.1 includes new functionality for enabling device detection. This post explains how developers can extend or customise the out of the box implementation.
Activating Device Detection
Sitecore has chosen Netbiscuits as the provider for identifying devices and describing the capabilities they have. The service requires a subscription through the Sitecore App Center which can be found in the Launch Pad of Sitecore 8. In the UK, the monthly subscription cost is £119.21 for unlimited detections per month and until this is activated, the device detection functionality described below is disabled.
You can find more information for setting up device detection on the Sitecore documentation site.
Using Device Detection
You can read about using Device Detection on the Sitecore documentation site which goes through all of the integration points that are offered out of the box. The following points describe how this default functionality can be extended.
Creating a Custom Provider
If you already have device detection on your site using a different provider then you may want to carry on using that provider. Sitecore documentation provides some useful developer information for configuring device detection and as with most Sitecore functionality, you can patch the default configuration to plug in your own provider. This means that you can get all of the above functionality but using a different implementation to the default Netbiscuits provider that ships with Sitecore 8.1. The configuration section which will need replacing is:
Using a custom include file to replace the default provider for your own implementation will provide you full control of the device detection functionality within Sitecore 8.1, for example:
The Sitecore documentation for the device detection API, along with the following skeleton class should be enough to get going with your own implementation of a device information provider:
Calling the base class's implementation of GetDeviceInformation ensures that the result is cached within the Sitecore DeviceItemsCache and therefore only 1 lookup is required per user agent (until the cache is cleared).
Sitecore Rules Engine Integration
One of the device detection integrations Sitecore provides is a set of rules for use with the Sitecore rules engine. The rules can be found under the item /sitecore/system/Settings/Rules/Definitions/Elements/Device and are described on the Sitecore Documentation site. There is also a guide on how to create new custom rules.
Sitecore Device Items & Device Detection
Another integration point for these rules are on the Sitecore device items found under
/sitecore/layout/Devices/Default. A new field, Rule, has been
added so that Sitecore will switch the user to that device item if the given rule evaluates
to true. For example, a Mobile Sitecore device item could use the rule
type is equal to Smartphone to activate it.
The rule configured on the Device Item is analysed within the HttpRequestBegin
pipeline step Sitecore.Pipelines.HttpRequest.DeviceResolver. This eventually calls
through into the method
to analyse the set rule against the visitor's request device. This shouldn't need to be
customised, but if you find yourself needing to override the default DeviceResolver
then bear this functionality in mind.
xDB also has an integration with Device Detection where reports can be generated showing a breakdown of visitors by device type and then further filtered down to show a report by device model. You can see an example report on the Sitecore documentation.
- Sitecore Documentation - Set up Device Detection
- Sitecore Documentation - Device Detection Rules
- Sitecore Documentation - Configuring Device Detection
- Sitecore Documentation - Creating Custom Rules
- Sitecore Documentation - Device Detection API
- Sitecore Documentation - Using Device Detection
Tags : Sitecore