Delivering personalized content to specific target audiences is a powerful way to attract website visitors and promote the right content to the right people, at the right time. This is how you can display products of regional interest to localized target groups, maybe display time-limited promotions to various user segments or highlight search-keyword related content for people that reached your website using these in a search engine. These are very typical scenarios that you expect to be covered by any system, capable of delivering content personalization. However, whenever we want to deliver personalized content for user segments, defined by some criteria that are not so trivial – for example customer ranking in your CRM or membership in groups, we hit a roadblock, as usually we are expected to use the built-in functionality only. Or at least that’s the case if you’re not using Sitefinity.
With the personalization feature Sitefinity brings the ability to deliver personalized content, targeted to specific audiences (user segments) based on certain criteria: location, profile fields, previous purchases, etc. You can build complex logical expressions in order to define precisely the audience you want to deliver your message to. And while the built-in criteria options will cover many scenarios, in case you need something custom, you still have that option to add a new criterion.
In my previous blog post I demonstrated how you can Integrate Sitefinity with SalesForce CRM. Now, in order to demonstrate implementing custom criteria, we will pull the rating of a lead in our CRM system (SalesForce). Our goal could be to show hot leads a promo code to give them that final push they need, before they place an order.
In order to add a custom criterion you need to:
- Create a dialog/editor for that criterion, where users will set its expected value (SalesForceRatingEditor.ascx).
In our case we need a simple drop-down with the possible lead rating values: hot, warm, cold. Set the Build Action for the *.ascx file to Embedded Resource.
- Create another editor for the personalization console (the “view website as” page), where you can test how the site will come up if the criterion is met and if it is not. We can also reuse the editor we already have (SalesForceRatingEditor.ascx) and simply hide the label and leave visible only the input fields.
- Create a resource file for the editors (CustomPersonalizationResources.cs). It should inherit from Telerik.Sitefinity.Localization.Resource. We need an entry for the criterion’s name and for the labels and values appearing on the editors.
We can then reference those elements on the editors like this:
- Create an evaluator, which will determine whether the currently logged user matches the criterion or not (SalesForceRatingEvaluator.cs). It implements the ICriterionEvaluator interface, i.e. the IsMatch method. As an input we get the value of the criteria set for the user segment and also the context of the request.
- Create the criterion. For that, we add an event handler for the Bootstrapper.Initialized event in the Global.asax file. Here we need to:
- Register the resource file
- Add a virtual path for the embedded resources (the editors)
- Create the criteria
- Register the evaluator for the criteria
- Finally, you can now use that criterion within your user segments
The source for the SalesForce personalization criteria sample is available for download from github.
If you’re looking for more info on the personalization feature in Sitefinity, we’ve prepared a whitepaper that explains its usage and benefits. You can review it here.