mtelligent

View Original

Personalization made easy with User Settings for Sitecore

I wanted to make it very easy to use Personalization with Sitecore, without having to worry about custom Facets and write a ton of custom code to make things work.

Out of the box with Sitecore, this is not very easy to do. First you need to define a custom model. Then you need to configure it for multiple service roles, including several Xconnect roles. Then you can write a bunch of code to deals with Xconnect API's every time you want to get or set its values. Never mind the additional effort need to creating custom personalization rules, Sitecore forms submit actions or the many steps needed to extend the experience profile to show that data.

To abstract all of this and make things easier for everyone, I have created a new Sitecore Foundation module:  User Settings for Sitecore.. It address all these by defining a custom Facet called “User Settings” that is implemented as a Dictionary of string Dictionaries, giving you the flexibility to organize your settings into "areas" that can be used to segment groups of data.

To make it easy to work with this data, I've implemented a Façade class that abstracts having to leverage Xconnect API's to fetch and return data. Just use the default indexers to get or set values directly into the façade:

UserSettings.Settings[key, area] = value;

If you're working client side with JavaScript, you can consume the included REST api that allows you to get or post updated individual settings or all the settings in an area: 

/api/sf/1.0/userSettings/

If you're working with Sitecore Forms, you can add our custom User Settings Submit action, which will store every value to a specified area.  

Once data is collected, you can use a visitors settings to personalize their experience. The User Settings personalization rule allows you to compare a setting in and area to any value you want.

If you're using SXA, you can install an optional Preferences module that adds a "Preferences List" component to the Composite tab of the SXA toolbox. When used you can define a set of options that when clicked, will update a configured UserSetting with the configured value for that option using the REST api.  

Finally, we added a new tab to the Experience profile so you can make it easy to see what settings have been set for a given user.

To see it in action, you can watch the following video.

Demo of User Settings for Sitecore module that makes it easy to personalize against forms data, or data captured with the preferences list component and view it on the experience profile.

If you want to better understand how it was implemented, I recorded this video that gives a deeper dive into the implementation:

Technical overview of implementation of User Settings module for Sitecore than provides a generic facet implementation, with a REST api, custom personalization rules, custom Sitecore Forms Submit Action and value providers, a custom Experience profile form and a custom SXA component to capture preferences.

You can download the packages to install on your own instance from the releases tab on Github.

Note that there are two Sitecore packages: one for the core User Settings module and an optional module for the SXA Preferences List component. In addition to these there is a zip file that needs to be unzipped at the root of your xConnect instance to register the custom facet types properly.