I did a "roll my own" implementation of Geo IP Location, instead of paying for the Sitecore one.
My data is getting recorded. I can see it under each contacts profile details.
But when I go into the Experience Analytics Dashboard > Audience > Locations the Country and Region show only [unknown country] and [unknown region]
The city is filled out just fine.
I am guessing this is because country and region are being expected in some specific format.
Here we see country is recorded for contacts.
But here, we see that all countries show up as unknown.
UPDATE: This is my implementation code:
using Newtonsoft.Json;
using Sitecore;
using Sitecore.Analytics.Lookups;
using Sitecore.Analytics.Model;
using Sitecore.Diagnostics;
using System;
using System.Net;
namespace MySite.Analytics
{
public class IPLookupProvider : LookupProviderBase
{
[UsedImplicitly]
public override WhoIsInformation GetInformationByIp(string ipAddress)
{
WhoIsInformation whois = new WhoIsInformation();
if (!string.IsNullOrWhiteSpace(ipAddress))
{
try
{
if (Location.IsPrivateIP(ipAddress) == false)
{
Uri geoLocationServiceUrl = new Uri("https://freegeoip.net/json/" + ipAddress);
WebClient client = new WebClient();
var serviceResponse = client.DownloadString(geoLocationServiceUrl);
dynamic serviceData = JsonConvert.DeserializeObject(serviceResponse);
whois.City = serviceData.city ?? string.Empty;
whois.MetroCode = serviceData.metro_code.ToString() ?? string.Empty;
whois.Region = serviceData.region_name ?? string.Empty;
whois.PostalCode = serviceData.zip_code ?? string.Empty;
whois.Country = serviceData.country_name ?? string.Empty;
whois.Latitude = serviceData.latitude ?? 0;
whois.Longitude = serviceData.longitude ?? 0;
}
}
catch (Exception ex)
{
Log.Error("JDA.Analytics.IPLookupProvider.GetInformationByIp: " + ex.StackTrace.ToString(), ex, "Location");
}
}
return whois;
}
}
}
And my patch file:
<lookupManager>
<patch:attribute name="defaultProvider">custom</patch:attribute>
<providers>
<add name="custom" type="MySite.Analytics.IPLookupProvider, MySite.Analytics"/>
</providers>
</lookupManager>
When I look in Mongo it appears that all the Country, Region, etc. fields are "N/A". But if I look at the details for the Contact they are populated.