[solved] GeoIP Problem

So, why does it locate my visits in the US, when I am in Germany? Why are many user countries listed as UserCountry_country_? Why do I suddenl have visitors from all over the world on a german website, if I haven’t had visitors from all these countries before according to the normal piwik location?
Don’t you think this is enaugh to think the data might perhaps not be right?

It looks like you haven’t set it up right. It doesn’t look at the moment like there is a problem with the data itself. Do you get the same UserCountry_country_ stuff if you reduce the report time to just today? I mean it is possible that all your old data that doesn’t have GeoIP data associated could be showing that (just an assumption). If that is not the case, then you likely have done something wrong during setup.

Yes, it’s also todays data. I mean there is not much you can do wrong in the setup, what do you think?
I just was not able to do the part

For more performance, it is recommanded to install the module apache mod_geoip. Configure your Apache according to: http://www.maxmind.com/app/mod_geoip

from the installation instructions on http://dev.piwik.org/trac/ticket/45.
But regarding the rest I did not see any problems.
Is there a way I can uninstall the plugin again and reinstall it then, maybe it will work properly then?
Thanks!

That module is really optional. I think you can disable the plugin, uninstall has to be done manually, probably. I can’t really tell you what’s wrong with your GeoIP setup, but it is apparent that something is wrong. The problem is likely not in the plugin files you installed, but in the path to the GeoIP data or some restriction/limit, so that the lookups don’t work correctly. Maybe it’s some missing permission or another restriction. Frankly, I wouldn’t run Piwik on a shared server. I would have a close look at the php error log. You can also check yourself with a small php script if the data retrieval and content from the GeoIP database works correctly.

Well, unfortunately I don’t have my own server.
I can’t really imagine a problem with the path, what do you mean with that?

This is all speculation. You have to walk thru the install instructions and make sure you followed them to the minute. I used them about a year ago or so and it worked fine from the beginning.
Then you could use a php script and check if the GeoIP lookup works better with it.

Okay, I am installing another Piwik on my webspace now and report every step here:

[ul]
[li] Downloaded the last Version 1.1.1 of Piwik
[/li][li] Opened the installation instructions on Installing Piwik - Analytics Platform - Matomo
[/li][li] Switched FTP Client to binary mode and uploaded the files without any problems
[/li][li] Opened the directory in the browser, welcome screen appeares
[/li][li] System check: No errors, one warning (Memory limit 64M. On a high traffic website, the archiving process may require more memory than currently allowed. If necessary, change the memory_limit directive in your php.ini file.) Should not be a problem for me, I don’t have so much traffic, I think.
[/li][li] Database setup: changed 127.0.0.1 to localhost and entered database name, pwd, … Go -> Tables created with success!
[/li][li] General Setup (entering superuser data) Go -> Success
[/li][li] Set up a website (entering the data of my website) -> No problems, I get the javascript code
[/li][li] Congratulations! Your Piwik installation is complete.
[/li][/ul]

Okay, I guess Piwik has been installed perfectly now!

I then inserted the code in my website.

Piwik locates me in the US, weird thing, since I am in Germany… I was in the US with my computer last year and my OS is in English, but how can that be?

Now I want to install the GeoIP Plugin:

[ul]
[li] I go to Plugin using GeoIP to accurately detect visitor countries, cities, and continent · Issue #5465 · matomo-org/matomo · GitHub and download the Piwik GeoIP Plugin.
[/li][li] Extract it and upload the extracted folder in the plugin directory, no problems.
[/li][li] I download the GeoLite City database from http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
[/li][li] Extract it and load it to plugins/GeoIP/libs/GeoLiteCity.dat
[/li][li] The filesize on the server matches exactly the one on my harddisk, seems like a successfull upload.
[/li][li] I ignore the part “For more performance, it is recommanded to install the module apache mod_geoip. Configure your Apache according to: GeoIP Legacy Apache Module « MaxMind Developer Site” of the installation instructions, since I don’t have full access to the server.
[/li][li] I enable the Plugin in the Piwik settings…
[/li][/ul]

What happens now after the activation:
I see the page:


Database Upgrade Required

Your Piwik database is out-of-date, and must be upgraded before you can continue.

The following plugins will be updated: GeoIP.

Important note for large Piwik installations

    * If you have a large Piwik database, updates might take too long to run in the browser. In this situation, you can execute the updates from your command line:
      php /webspace/10/53299/statistics.good4media.de/index.php -- "module=CoreUpdater"
    * If you are not able to use the command line updater and if Piwik fails to upgrade (due to a timeout of the database, a browser timeout, or any other issue), you could manually execute the SQL queries to update Piwik.
      › Click here to view and copy the list of SQL queries that will get executed

      # Note: if you manually execute these queries, it is expected that some of them fail. In this case, simply ignore the errors, and run the next ones in the list.

         UPDATE piwik_option SET option_value = "0.9" WHERE option_name = "version_GeoIP";


and click on Upgrade Piwik.

-> Piwik has been successfully updated!

I go back to Piwik as the page tells me to.

Now I want to update my past reports:

[ul]
[li] I run the file /plugins/GeoIP/misc/geoipUpdateRows.php in my browser.
[/li][li] Here I get the warning:
[/li]Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit in safe mode in /plugins/GeoIP/misc/geoipUpdateRows.php on line 17
[li] Maybe this was the problem before?
[/li][li] I edit the file and delete the line

set_time_limit(0);

. I upload the edited file and execute it again.
[/li][li] I see a blank page, hmm, at least no errors.
[/li][li] I drop the tables piwik_archive_blob_2011_01 and piwik_archive_numeric_2011_01
[/li][li] Half the visitors in Locations & Provider are listed as UserCountry_country_ the other half is from Germany as expected. In the continent section half Europe, half UserCountry_continent_. Also the providers are listed.
[/li][li] Still no cities listed here, nope, none at all. They should be in the Locations & Provider section, right?
[/li][li] The question is: What is the problem now? Why are no cities listed and why are many countries not detected at all?
[/li][/ul]

I hope you can help me to fix these problems with this detailed report.
I saw that the current version of CityLite Geo is from January 1st, 2010, could that be a reason for the problems? A new version will be available on February 1st, 2011, so I will see that soon.
I don’t understand, why no cities are shown at all! If the cities were wrong I would understand it, but that they are not shown at all? That seems to have something to do with Piwik…

When I tryed to locate my self via Your IP Address's GeoIP2 Data | MaxMind I was located in a neighbouring city. Okay, that would be fine.

I hope you can help me to fix the problem with this new info.
Thanks,
Stefan

The GeoIP plugin is not fully integrated into Piwik. The plugin adds its own geolocated columns for its widgets, which actually overlap some in Piwik (i.e., country and continent). The existing Piwik widgets don’t use the columns added by GeoIP.

UserCountry_country_ and UserCountry_continent_ are because GeoIP returns an empty string when it can’t geolocate an IP address. Piwik expects it return ‘xx’.

These functional and integration issues will be addressed when we move GeoIP into the base distribution.

Thanks for your reply, do you already have an idea, when geoip will be integrated?
The thing I am wondering about most is, why I don’t see any cities in the locations tab, because that is why I initially installed the plugin. Even if the location would be bad I should see some cities, which might not be correct, but I should see them, right?
So what is the problem there, why don’t I get any cities in the locations tab?
Thanks a lot!

To clarify what I said, the “Locations and Provider” tab doesn’t know anything about the GeoIP columns; so, no, cities will not show up there. For now, you’ll have to look at the widgets offered by the plugin.

Sorry, I don’t have an ETA to complete the integration. Cross your fingers…maybe it’ll be in 1.2.

Okay, but if the Locations & Providers tab doesn’t know anything about it, why does it now show the GeoIP info for country and continent instead of the normal one from piwik?
In the end I just want to know how I can make piwik or the plugin show me the cities. Somehow people managed to do so, so I guess my version should be able to do it, too, but how? The only way I know to add widgets is on the dashboard, but there in the GeoIP section, only countries and continents is listed. So how do other people get to see the cities?
Thanks!

Munich, that it doesn’t work with Locations and Providers has been told right from the beginning of this thread. If you want to see cities then look at the GeoIP Visitors Countries widget. And, as I said earlier, be prepared that half of them are wrong, because country-wide providers also assign IP numbers country-wide and not regional or per city. There is no way to avoid this.

man, now I figured it out, it wasn’t an extra section in locations & providers, it was just about clicking on the country and then the cities are listed.
that was all I wanted to know, lol!

[quote=munich]
Okay, but if the Locations & Providers tab doesn’t know anything about it, why does it now show the GeoIP info for country and continent instead of the normal one from piwik?
In the end I just want to know how I can make piwik or the plugin show me the cities. Somehow people managed to do so, so I guess my version should be able to do it, too, but how? The only way I know to add widgets is on the dashboard, but there in the GeoIP section, only countries and continents is listed. So how do other people get to see the cities?
Thanks![/quote]
There may have been a misunderstanding. The Providers widget will not be able to show any GeoIP info. The widgets that say “Country (GeoIP)” etc. do show GeoIP info. What do they show for you? And they also show cities. Do you have the “Country (GeoIP)” and “Continent (GeoIP)” widgets on the “Providers and Locations” tab?

Ah, I see you figured it out while I was writing the other reply :slight_smile:

Btw, as a clarification, I do not get “UserCountry_country_” or some such, never. There is an “Unknown” then and the rate is about 2% of visitors.

[quote=munich]

I hope you can help me to fix the problem with this new info.
Thanks,
Stefan[/quote]

Hi Stefan,

same here, but I fixed it.

I installed the plugin earlier and had the same problem. Basically, the geoipUpdateRows.php script will only update the first row in the piwik_log_visit table for each batch of 1000 rows fetched, leaving the other rows with all fields set to NULL. This means that if your table only has a small number of rows, < 1000 (as in my case since my Piwik install is new - I had 159 rows), then only the very first row will be updated.

When you then drop the piwik_archive* tables and regenerated the reports, you will only see wrong data, i.e. UserCountry_country_ in the countries list.

There seems to be a problem in the file GeoIP.php, in the function updateExistingVisitsWithGeoIpData().
The inner loop that updates the rows seems wrong to me.

Anyway, the quickest fix in my case, was replacing $limit = 1000; with $limit = 1;.
It processed one row per time this way, but I didn’t bother changing more the code as I only had, as said, 159 rows in that table.

Hope this helps.
Vito

Sorry to sound like a total noob here, but could you tell me how you dropped the old piwik_archive tables so that it reprocesses previous visitors? Thanks.

Uli

Good news: GeoIP is now integrated in Piwik, enabling Accurate Visitors Geolocation in your Analytics reports. To enable GeoIP go to the Settings > Geolocation admin page, and follow the short instructions.

You can also get an even more accurate Country & City Database from here to enjoy top accuracy in detecting your visitors locations.

See also the documentation about Geolocation - Analytics Reports in Piwik.

A post was split to a new topic: GeoIP not working