Personalisation Groups is an Umbraco package intended to allow personalisation of content to different groups of site visitors. It comes with some document types, data types and custom property editors to allow you to define groups based on given criteria and an extension method on IPublishedContent to allow you to show or hide content according to these criteria in your templates.
It comes with a number of criteria, namely:
And is extensible so you can write your own.
Please note this package is marked as beta, primarily as whilst it is being used by others, it's not yet been used in a production setting myself.
That said, I think it's reasonably solid and have had some good reports, so feel free to take a look and use as you see fit.
For more detailed information on use, extending the package, troubleshooting info or to review and/or contribute to the source code, see the documentation and source code repository at Github: https://github.com/AndyButland/UmbracoPersonalisationGroups
Using the package
Firstly install the package in the usual way.
Once installed you'll find a few additional components:
There's also a NuGet installer if you prefer to use that:
PM> Install-Package UmbracoPersonalisationGroups
However this will only install the dll, not the document types and data types. As such I'd reccommend if you do want to use NuGet for ease of updates, do the following:
Personalising repeated content
A typical example would be to personalise a list of repeated content to only show items that are appropriate for the current site visitor. Here's how you might do that:
@foreach (var post in Model.Content.Children.Where(x => x.ShowToVisitor()))
With a little more work you can also personalise an individual page. One way to do this would be to create sub-nodes of a page of a new type called e.g. Page Variation. This document type should contain all the fields common to the parent page that you might want to personalise - e.g. title, body text, image - and an instance of the Personalisation group picker.
You could then implement some logic on the parent page template to pull back the first of the sub-nodes that match the current site visitor. If one is found, you can display the content from that sub-node rather than what's defined for the page. And if not, display the default content for the page. Something like:
var personalisedContent = Model.Content.Children.Where(x => x.ShowToVisitor()).FirstOrDefault();
string title, bodyText;
if (personalisedContent != null)
title = personalisedContent.Name;
bodyText = personalisedContent.GetPropertyValue<string>("bodyText");
title = Model.Content.Name;
bodyText = Model.Content.GetPropertyValue<string>("bodyText");
Notes on particular criteria
The country criteria uses the free GeoLite2 IP to country database which you can download from: http://dev.maxmind.com/geoip/geoip2/geolite2/ and made available by Maxmind.com. It'll look for it in /App_Data/GeoLite2-Country.mmdb or at the path specified in the following appSetting:
<add key="personalisationGroups.geoLocationCountryDatabasePath" value="/my/custom/relative/path"/>
Extending the package
Personalisation groups comes with a number of built-in criteria but may not have everything you want to use. However it can be extended relatively easily.
One way to do this would be to use one of the "low-level" built-in criteria, such as the ones that look for a cookie or session value. If your application code can set a given cookie or session key value when a particular action occurs you want to personalise on, you can just do that and use them.
Or you can create your own criteria. This involves writing some server-side code that implements a given interface as well as some custom angular views and controllers. There's more detail on this here: https://github.com/AndyButland/UmbracoPersonalisationGroups#how-to-extend-it
And several examples in the source code you can use for reference: https://github.com/AndyButland/UmbracoPersonalisationGroups/tree/master/Zone.UmbracoPersonalisationGroups/Criteria