Content personalization in sitecore8 based on country with Maxmind GeoIP
free Service

One of my
client requirement was to personalize the sitecore content based on the country(Geo-Ip).
And they were using free geo-ip country database provided by maxmind.

Site core
Personalization (country rules) is tightly coupled with analytic database so we
need to customize the  sitecore condition
to call geolite country database file to resolve the country ip address.
So below is
the step by step process to implement this solution:
Configure the layout with rule and
Step1. Go to the sitecore > Item >

Step2. Add new condition and edit rule

Step3. In rule editor, select geo-ip
condition and provide value of compareto and specific country
attribute as below

Step4. Select the presentation content> select the datasource

Step5. You can add n number of condition with default condition

Not working…ohh missed one step, now one sitecore presentation task has been
done but still personalization condition is point to analytic dll, we need to
override that condition with custom dll, as below:
Kindly refer my blog to find the new path
of condition item in sitecore 8

Need to change the type as below:

          Class name, Namespace

Below is the sample code for custom class
public class LiteCountryCondition<T> : CountryCondition<T> where T : RuleContext
        protected override string GetColumnValue(VisitorDataSet.VisitsRow visit)
                string countryCode = string.Empty;

                if (Sitecore.Context.Item != null)
                    LookupService lookupService =
                           new LookupService(
                    Country country = lookupService.getCountry(HttpContext.Current.Request.UserHostAddress);
                    return country.getCode();
                return countryCode;

            catch (Exception ex)
                Sitecore.Diagnostics.Log.Error(string.Format("LiteCountryCondition: Exception: {0}, Inner Exception: {1},  LiteCountryCondition : GetColumnValue",
                    ex.Message, ex.InnerException != null ? ex.InnerException.Message : string.Empty), this);
                return "";


I Hope you enjoyed this article..

Appreciate to your suggestion and comments

Happy sitecore 🙂

Leave a Reply

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