3

I Have enabled Sitecore GEOIP services to my local instance and tried personalization based on country.

This not worked as I worked local environment so it returns the local IP address (127.0.0.1).

So I have decided to create a custom rule.

In that rule text, I just copied the query of the existing country and created my own class.

In that class, I just returned the country name and checked it's not working.

So then I checked the country data source, each country having a field ["Country Code"].

So I decided to return country code still it's not working.

Below I attached the image of this.

enter image description here

namespace Multisite.Models
{
    public class CustomCountryNameCondition<T> : VisitCondition<T> where T : RuleContext
    {
        protected override string GetVisitStringValue(CurrentInteraction visit)
        {
            string ipAddress = new WebClient().DownloadString("https://api.ipify.org");
            var locationObject = LookupManager.GetWhoIsInformationByIp(ipAddress);
            // var cultureInfo = new CultureInfo(locationObject.Country);
            // var Country = new RegionInfo(cultureInfo.Name);
            //return Country.EnglishName;        
            return locationObject.Country;
        }      


    }
}

Any help appreciated..!

| improve this question | | | | |
  • 2
    Just a suggestion that you can use chrome plugin chrome.google.com/webstore/detail/sitecore-analytics-testin/… to specifying a forwarded IP address for GeoIP lookups – Swati Gupta Nov 21 '19 at 8:51
  • I have installed and tried the Sitecore default GeoIP rule and that is not triggering. – Rajasekar Nov 21 '19 at 9:08
  • Does this return locationObject.Country correctly? Also you are making a web api call in a personalization rule. This rule may run 10 times on a page. So you would be adding the API times 10 on page loads. I would use the out of the box Sitecore rule and just use the Google Extension to fake the IP. – Chris Auer Nov 21 '19 at 16:40
0

When you say it's not working, Does it execute your Custom Rule (can be verified if you write Log information or Debug in local)?

As you have mentioned that you tried the Sitecore Analytics Testing tools extension and it didn't trigger as well (sounds like the same problem). I've faced this before when I created my own Custom Rule and was clueless as it wasn't working at all in lower environments (same happened with Chrome extension as well).

Hence, make sure your Xdb Tracking setting (Xdb.Tracking.Enabled) is set to true under Sitecore.Xdb.config (or verify it usingshowconfig utility) in order for Personalization Rules to trigger even though your Xdb is enabled (Xdb.Enabled). I hope it helps!

| improve this answer | | | | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.