Content: Blog

Technical articles

Segmentation and Personalization with django CMS

Martin Koistinen

May 5, 2015


Unless you’re a frequent traveller who happens to also visit the Divio website regularly, you probably don’t realize that shows you different content if you’re physically in Switzerland versus anywhere else.

Here’s what it looks like for the Swiss (first) and everyone else (second):


Divio does this because many of their customers are leading Swiss companies who have strong name-recognition in the Swiss market, but less so around the globe. Its smart, effective and is a simple example of Segmentation.

Other organizations use segmentation in different ways. Some companies employ the capability to present just-in-time offers to visitors who have arrived at the company website by responding to an online advertising campaign, others use it to display new content that the incoming visitor is likely to enjoy based on their profile, still others may use segmentation to present offers that only apply to visitors from specific geographical regions. Not every website needs it, but it can be a powerful way to provide a more personal and ultimately more engaging experience for your web viewers.

Since django CMS is sitting on top of Django, a World-class web framework, CMS developers have always had the ability to provide these sorts of personalization techniques, but it previously required project-specific code in CMSApps or CMSPlugins. Aldryn Segmentation was built to make things much more approachable for every django CMS user. By using the familiar drag and drop interface of the CMS structure mode, a content manager can create arbitrary logical rules for when to display certain content based on meta-data in the incoming visitor’s HttpRequest object.

Out of the box, Aldryn Segmentation lets you segment your users based on their HTTP Cookies as well as their Django authentication status. It also offers a simple switch (on/off) for testing and other uses. Being able to segment on cookies provides a tremendous number of possibilities all by itself, and the package even offers a bonus CMSPlugin that can set cookies too, so once your users have, for example, visited the landing page of your company’s latest Ad Words campaign, you can then provide follow-up content on other pages immediately or even for subsequent visits.

Aldryn Segmentation was developed with teams of content managers in mind. Each logged-in content manager has the ability to preview how the site’s content will change for different users, so, the content manager doesn’t have to change their own cookies, authentication status or physical location just to see and work with the content. All segmentation criteria currently in use are available for overriding in a custom menu CMS’s toolbar.


The package is fully translated and localized for content management teams wherever they may be located in your organization, and, each content manager can preview their work with their own criteria without affecting anyone else, making it suitable for global teams and agencies.

Aldryn Country Segment, the plugin actually used in the Divio examples above, is part of a companion package that was released alongside the main package and provides the powerful capability of segmenting incoming visitors based on their country of origin. This was split from the main package because it requires the installation of the MaxMind GeoIP C-API and one of their excellent datasets. The free GeoLite Country dataset provides superb results already and for more demanding scenarios, they offer even better datasets. (Fortunately, Aldryn users won’t have to do any of this, as it is built into the platform.)

Aldryn Country Segment just plugs into the Aldryn Segmentation package providing country-based segmentation criteria right alongside the other, built-in criteria, so, segmenting with rules like “show special offer content to business customers only in France but who have not logged-in” is natural and straight-forward to declare. Aldryn Segmentation was developed to be extensible and Aldryn Country Segment additionally serves as a reference implementation for new criteria plugins. With a few lines of code, new criteria can be created to support almost any project need.

Its also an open-source package on GitHub, so, hopefully before long, the community will provide new plugins to provide additional segmentation criteria such as:

  • Browser/OS - A software company could offer the right type download depending on the visitors operating system;
  • Referrering Site - Show specific products if the user arrived from a Google search listing, based on what they searched for;
  • Client IP Address - If the visitor is arriving from your companies target company list, show them special, targeted content;
  • Django Session - The developer could create numerous static criteria or even more complex programmatic rules without relying on as many cookies;
  • Date/Time - Not strictly a personalization/segmentation criterion, but useful none-the-less. Imagine that a restaurant could feature their lunch specials in the afternoon, and their wine-selection in the evening and/or, their brunch menu only on the weekends.

For a developer-focused walk-through of these packages, checkout the YouTube video here:

Happy segmenting!

blog comments powered by Disqus

Do you want to test django CMS?

Try django CMS