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.
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..!