WCM tip #30: Persist the Device Channel choice using the DeviceChannel cookie

SharePoint 2013 Publishing Site
When switching between the different Device Channels you can persist the choice using the DeviceChannel cookie.

Using Device Channels in SharePoint 2013 you can optimize how your website is displayed for different devices. At least if you follow the original idea behind Device Channels, because in reality you can apply it to any kind of scenario that involves serving different user experiences to your users. Optimizing your website for anonymous visitors or improving accessibility are just two samples that go beyond the original idea of using Device Channels.

When using Device Channels as they have been originally designed, the associated user-agent substring will automatically take care for the right Device Channel to be applied for the particular device. If however, you are using Device Channels for other purposes, you have to take care for switching to the right Device Channel yourself. The most common way to switch to the specific Device Channel is to add the DeviceChannel query string parameter to the URL of the current page and pass the alias of the desired Device Channel. While this will switch to the chosen Device Channel, the choice will apply to that particular page only. As soon as you click on any link, SharePoint 2013 will switch back to the Default Device Channel. If you want to persist the choice, instead of setting a Device Channel using a query string parameter you can use a cookie instead. By setting a cookie called DeviceChannel with the alias of the desired Device Channel, you can serve all pages using the particular Device Channel for as long as necessary.


comments powered by Disqus