Sitecore Predefined Rules for Geolocation Conditions

I was recently working with a project team to define an approach to personalize content based on the region of visitors. When you think “region of the visitor” you may be thinking about the Region attribute from Sitecore Geolocation data. For this particular Sitecore site our client has their own definitions of what regions are. The client is a Massachusetts-only company and wants to target content across four types of areas of the state, or what they call regions to them: Coastal, City, Rural, Suburb. The key is that they have specific zip codes to map to these four regions. Let’s figure out how we can make this work without any custom code.

Approach

The general approach is to build four predefined conditions in Sitecore that we can use as our four region conditions. Think of Sitecore “predefined rules” as complicated composite rules that you might re-use over and over with a friendly name. By creating these once, we can apply them in any case where we have a rules field (e.g. personalization).

Create the Predefined Condition

  1. Navigate to Marketing Control Panel > Personalization > Predefined Rules
  2. Create a predefined rule for each of the four region scenarios, like in the image below:

In each predefined rule you can populate the rules field with all the inner composite details with the zip codes. In this case the regions have many zip codes, but this content population effort in the rule is a one-time pain we deal with up front. The image below shows just two zip codes but you can build the rule up as big as you need with all of the possible zips.
Note: Sitecore’s geolocation data captures zip code in the Postal Code attribute.

Use the Predefined Conditions for Personalization

So how do we make use of these composite rules we painstakingly populated with hundreds of zip codes?

When you personalize a rendering, there’s a condition to select where a specific predefined rule evaluates to true:

In the dialog you would select one of the four predefined rules you created for this personalization scenario:

Now you can set a unique data source based on this region and re-use these rules over and over without having to type in all of the zip codes on multiple pages.

 

Mark Ursino

Mark is Sr. Director at Rightpoint and a Sitecore MVP.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.