Skip to content

jdearsley/Sitecore.51Degrees.CloudDeviceDetection

 
 

Repository files navigation

##What does it do?

This project provides device detection for Sitecore using the cloud web service provided by 51 Degrees (https://51degrees.com/products/device-detection/cloud).

It provides 4 things:

  1. A preprocessRequest pipeline step to populate the Request.Browser with properties from 51degrees
  2. An HttpRequestBegin pipeline step to run a condition set on the Sitecore Device item to determine context device. (not required for Sitecore 8 projects)
  3. A set of rules that can be used for Conditional Renderings:
  • when the visitor's device is a:
    • Mobile
    • Tablet
    • Games Console
    • eReader
    • Media Hub
    • Small Screen
    • TV
  • when a visitor has a specific browser (e.g. Chrome)
  • when a visitor's browser version matches a condition
  • when a visitor is on a specific platform (e.g. iOS)
  • when a visitor is on a specific platform version
  • when a visitor's screen width pixels matches a condition
  • when a visitor's screen height pixels matches a condition
  1. A 51Degrees implementation of DeviceInformationProviderBase to enable built in Device Detection functionality within Sitecore 8 and Device Reporting within Experience Analytics of xDB

##What prerequisites do you need?

To use this module, you will need to sign up for an account with 51 degrees, all rules provided are available on their free tier.

For full Device Detection functionality in Sitecore 8, a Premium Cloud subscription is required. If using the free subscription, the things that won't be reported are:

  • Platform Vendor
  • Hardware model
  • HasTouchScreen
  • Javascript

##Installation

  1. Install the Sitecore package /SitecorePackages/Sitecore.51Degrees.CloudDeviceDetection.zip
  • If you are using Sitecore 8, click Skip on any conflicts (extra items are needed for compatibility with older Sitecore versions)
  1. Do an Incremental Site Publish
  2. Open /App_Config/Include/Z.Sitecore.51Degrees.CloudDeviceDetection/Sitecore.51Degrees.CloudDeviceDetection.config and enter your license key in the setting Sitecore.FiftyOneDegrees.CloudDeviceDetection.ApiLicenceKey
  3. If you are using Sitecore 8 and xDB, rename _/App_Config/Include/Z.Sitecore.51Degrees.CloudDeviceDetection/Sitecore.51Degrees.CloudDeviceDetection.xDB.config.bak to remove the .bak extension
  • If also using the free tier, remove the Sitecore.FiftyOneDegrees.CloudDeviceDetection.ApiEndpoint setting from this file to revert back to the basic settings

To check that the plugin is working, navigate to _/Sitecore/Admin/DeviceDetectionStatus.aspx where you should see details about your device if the module is working.

##Customisations

A 51degrees endpoint is provided by default in the setting Sitecore.FiftyOneDegrees.CloudDeviceDetection.ApiEndpoint, you can override this but the module requires the values of IsMobile, DeviceType, IsConsole, IsEReader, IsMediaHub, IsSmallScreen, IsSmartPhone, IsTablet, IsTv, BrowserName, BrowserVersion, ScreenPixelsHeight, ScreenPixelsWidth, PlatformName and PlatformVersion to function.

The additional device resolver step is plumbed in after the the default Sitecore device resolver and will only run if the Sitecore device resolver has resolved the device to the default device. If the default device has been resolved, then the module will run the new pipeline resolveMobileDevice. This has been split into several steps to allow additional steps to be inserted into the pipeline to customise it's behaviour.

To extend the module further, you can add additional querystring parameters to the setting Sitecore.FiftyOneDegrees.CloudDeviceDetection.ApiEndpoint based on the property dictionary (https://51degrees.com/resources/property-dictionary). Once this is done, the new properties can be accessed by calling the following code:

HttpContext.Current.Request.Browser["PROPERTYNAME"]

Or

using Sitecore.FiftyOneDegrees.CloudDeviceDetection.Services;
using Sitecore.FiftyOneDegrees.CloudDeviceDetection.System.Wrappers;

...

IBrowserCapabilitiesService browserCapabilitiesService = new BrowserCapabilitiesService(new HttpContextWrapper().Request);
browserCapabilitiesService.GetStringProperty(propertyName);
browserCapabilitiesService.GetBoolProperty(propertyName);
browserCapabilitiesService.GetIntegerProperty(propertyName);
browserCapabilitiesService.GetDecimalProperty(propertyName);

About

Sitecore Device Detection module using the cloud service provided by 51degrees.com (https://51degrees.com/products/device-detection/cloud)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 89.2%
  • Classic ASP 10.8%