4

Is there an easy way to test if GeoIP is enabled and working correctly?

  • I don't understand your comment, if xDB is disabled then how are you testing for GeoIPs? – Amitabh Vyas Dec 2 '17 at 0:06
5

You should be able to setup a test file to test if the GeoIp service is working correctly. I'd recommend following Solution 3 in the Sitecore support issue below:

https://kb.sitecore.net/articles/798498

Basically you need to drop code like the following on your server. Ideally in a location under the /sitecore path to protect just anyone from accessing the page.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestIp.aspx.cs" %>
<%@ Import Namespace="Sitecore.Analytics.Lookups" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
    <script runat="server">
        protected void Button1_Click(object sender, EventArgs e)
        {
            var w = LookupManager.GetInformationByIp(TextBox1.Text);
            ListBox1.Items.Clear();
            ListBox1.Items.Add("IP: " + TextBox1.Text);
            ListBox1.Items.Add("AreaCode: " + w.AreaCode);
            ListBox1.Items.Add("BusinessName: " + w.BusinessName);
            ListBox1.Items.Add("City: " + w.City);
            ListBox1.Items.Add("Country: " + w.Country);
            ListBox1.Items.Add("Dns: " + w.Dns);
            ListBox1.Items.Add("Isp: " + w.Isp);
            ListBox1.Items.Add("Latitude: " + w.Latitude);
            ListBox1.Items.Add("Longitude: " + w.Longitude);
            ListBox1.Items.Add("MetroCode: " + w.MetroCode);
            ListBox1.Items.Add("PostalCode: " + w.PostalCode);
            ListBox1.Items.Add("Region: " + w.Region);
            ListBox1.Items.Add("Url: " + w.Url);
        }
    </script>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:TextBox ID="TextBox1" runat="server" Width="229px"></asp:TextBox>
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="GetInformartionByIP" Width="234px" />

        <br />
        <asp:ListBox ID="ListBox1" runat="server" Height="314px" Width="557px"></asp:ListBox>

    </div>
    </form>
</body>
</html>
  • Hi thank you for the reply. i tried solution #3 but i am getting the following error "Null ids are not allowed. Parameter name: endpoint". xdb is disabled but GeoIp should still be working. – Naim Alkouki Nov 9 '17 at 14:59
  • 2
    Naim, your question asks if there is a way to test if Geo IP is enabled and working. I believe this answer adresses this question, don't you? – Mark Cassidy Nov 9 '17 at 17:55
  • Hi Mark, yes but still did not solve my problem, i am still not sure whats wrong with the GeoIp for the site in hands. the sitecore testing page is throwing an exception too. – Naim Alkouki Nov 9 '17 at 19:20
2

although Dylan's answer is correct but I would like to add few more points here -

if you still receiving incorrect information?

  • Check whether the correct IP information is stored in the Analytics database

    Sitecore 7.5 – Sitecore 8.x: the “GeoIps” collection, Collection database (MongoDB)
    Sitecore 6.4.1 – Sitecore 7.2: the “GeoIps” table, Analytics database (SQL)
    
  • If incorrect Geo location information stared for a given IP, deleted that incorrect IP info from the GeoIps table/collection and do an IIS reset.

    You have to change the IP address into hash format.
    
  • Check correct Geo information will be cached/stored again in the next request
  • I will note this is something that he should look into if he finds that what I describe above is returning valid data. Because GetInformationByIP will make a direct request to the Geo IP Provider and will not use the various caching and analytics data storage methods that you are describing above. But good information. – Dylan Young Nov 9 '17 at 4:30
  • Hi, thank you for your answer but the xdb is disabled. – Naim Alkouki Nov 9 '17 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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