-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin using GeoIP to accurately detect visitor countries, cities, and continent #5465
Comments
Thanks for the wonderful work on this plugin, it’s really great! Just wanted to add my little contribution with a little feature I use and thought I would share. By applying the patch ‘patch_GeoIP_0.7_google_map_link’ I just uploaded to the original tree it adds links to google maps with the location of cities in the visitor countries dropdown… |
mike5464 and rembrand, the plugin should show “Unknown” when the visitor couldn’t be located. It will only work well from the upgrade and not fix previous visits. Do you still experience the issue few days after the upgrade? |
You're using mod_geoip, right? Here's an excerpt from my apache conf: <IfModule mod_geoip.c> Furthermore, check permissions on GeoLiteCity.dat, try chown <apacheuser> /path/to/GeoLiteCity.dat |
wrote a small php script to test the Funktion of Geoip:
Output : array(4) { [ string(2) "de" "city"=> string(7) "Hamburg" [ float(53.55) "longitude"=> float(10) } Piwik still displays UserCountry_country_ for new requests... |
I've extended the GeoIP plugin to track in detail (In the US and Canada) which state or region the visitors are from, by adding an extra column to the database (region) and making minor changes to the code. The region can be query from the maxmind db. I was wondering if this feature can be made public? |
duylaiabc, can you please post a screenshot of how the reporting look like? |
it tried to get location_geoip_latitude, location_geoip_longitude from api.
But the result is, most of the data have wrong lat and long values. E.g.:
as you can see, loc data of Leonding is correct, but data of Vienna isn't. |
for people with limited memory you can replace
into
in GeoIP.php |
Replying to matt:
I tested this with the MySQL version of the maxmind database (!http://ipinfodb.com/ip_database.php) and modified the plugin to perform a mysql lookup instead of the binary database and ran the update script several times. A lookup via MySQL takes about 25% longer than the current version and the mysql tables take up about 300 MB. So it's no benefit whatsoever. |
Is this plugin still in development? I would like to use the data from this plugin to show the visitors on Google Maps (or another map service)... |
DaSilva, you are welcome to contribute to the plugin. Ideally, you would post a screenshot and a link to your example piwik with the plugin installed so we can have a look and provide Feedback. When your work is done, we can consider including it in the GeoIp plugin. |
Replying to thibaut:
I don't know what your problem is, but I have been using this plugins for months, and it is still working with 0.5.4 on my server. |
I have all the time the "unknown" problem and sometimes "UserCountry_country_--" - but most of the time the country-detection works fine. Has someone some steps I could try? |
Replying to anamela:
mmh. this is not realy working for me.
and instead of cities i see all the time "Unknown" :-( |
After installing everything except this step "For more performance, it is recommanded to install the module apache mod_geoip. Configure your Apache according to:" piwik tracks nothing anymore. After deactivation everythings works fine. I changed all my previous reports. I've changed the PIWIK_INCLUDE_PATH to my local path in the geoipUpdateRows.php. After that change i could update all my old reports and it works fine. But the problem now is that I couldn't track any new visitor. |
php 5.2 + mysql 5.0.X SLES 10.3 distribution. By the way, using geoipUpdateRows.php script from command line only. |
Is it possible that in the archived data the latitude and longitude will be stored in the database. Would like to use this for a maps plugin. |
In Piwik 0.6, there is a backward incompatible API change in the archiving code. All GeoIP users will need to upgrade to the latest GeoIP pluginafter they upgrade Piwik to 0.6. Piwik will automatically disable the GeoIP plugin during the upgrade to 0.6. |
Hi, I have recently installed the latest version of Piwik .5.5 and it all works fine. I then installed Geoip and again it worked except I get the following problems... Country (GeoIP) UserCountry_country_ 218 and Continent (GeoIP) UserCountry_continent_ 218 I have looked through this thread and do not see a solution? Is there one and if so what can be done? regards, Blair |
Hi, I developed some kind of patch to store regions more than city (I find it more practice). Please feel free to tell me if you see something wrong in this patch. |
Replying to e.marguin:
|
ok i'll just try to translate here the main things (i'm sorry by advance for my poor english)... The geoip module gives us information about the city of visitors. But often we do not know this city because it's too small. That's why I prefer to display regions, like in the other web analyzers tools. The patch give upper stores the region name in db instead of the city name. To install it, just extract it into the plugin/GeoIP/ folder. Eric |
Replying to e.marguin:
|
mike3050, please don't add links to your websites in the trac comments, thank you. |
Hi, || Continent (GeoIP) |||| |
Replying to snowdiver:
EDIT: Problem solved. The apache module is installed on my server, but doesn't provide enough geo-information. Switching the module-search off fixed this problem! |
Replying to snowdiver:
sorry, i am not that fit with all these server, php, etc stuff. i am using piwik and geoip and have the same "unknown" problem. but i dont have an own server, my homepage is on a freehoster-server (bplaced.net). is it possible to do what you did when i am using a free-hoster?? thanks! |
Replying to theodorius123:
My homepage is also hosted on bplaced.net servers, so we met the same problem. It is just a small modification of the GeoIP.php file. Just remove or comment lines 230-234 to force the plugin to use the GeoLiteCity.dat file instead of the Apache Module, which in the bplaced.net case does not provide information about the city of a visitor. |
The most frequent "city" in my stats is "unknown". Any suggestion for a better geoip database? I'm concerned only with Brazil, FWIW. |
All users experimenting issues with the geoipUpdateRows.php script, we have fixed a few bugs reported by users in this thread. Check out the new GeoIP 0.14 version. If you still have issues, please report here, we'll do our best to fix it. Users that are seeing a lot of 'unknown' countries and cities, this is probably due to the low coverage of the Free IP to country database provided by MaxMind. If anyone knows a better DB, let us know! You can alternatively buy the MaxMind pro DB, but I haven't tested how accurate this DB is. |
I have it installed on Apache 2.2.17 and it works fine. |
Suggeston to add:
in row 51 in GeoIP/Controller.php Providers table will still have Row Evolution function |
@mcantsin this plugin is working for me and many others, are you sure mod_geoip is active and configured?
Then access that file via your webserver http://yourserver.com/geoiptest.php Now you should have a couple of replies that states GEOIP information, for example:
if that is not working go to the link above http://dev.maxmind.com/geoip/mod_geoip2 and make sure the .dat file is in the right folder and readable for the webserver |
Hmm, i found there is a Problem with the install process. When i run the geoipUpdateRows.php i get this error
There is a field missing and we have a php error. So nothing is logged to Piwik with GeopIP is enabled. |
@greg I added the following line in GeoIP.php so it handles live visitors on my install.
@ManuelW it appears you are running the latest GeoIP without the install() function being run, I don't know how to force it to reinstall but if you know how to add SQL columns run this:
|
Attachment: 0.18 with minor changes (disabled row evolution, region changes by greg) |
Replying to dbmz:
is it added in the new GeoIP.2.zip also?
|
Replying to ManuelW:
|
When GeoIP is enabled as an Apache module GeoIP won't work. It throws a Fatal Error like so: My hosting provider is Hosteurope. I'm on a shared hosting there (Webpack L). Hopefully there is a solution soon. |
As far as I know it is not possible for apache modules to declare PHP functions. It is possible that someone at your shared host is autoloading the geoip functions, to check create a new file get_defined_functions.php with the following content
access it via your webbrowser and search for the function there, pay extra attention to functions under the "user" tag. I'm not very familiar with autoloading functions, is piwik installed as a seperate site (VirtualHost) in your apache config? |
I have a weird problem. |
I patched GeoIP plugin to fix bug in live data.
and add
If you also want to modify your old data, update "updateExistingVisitsWithGeoIpData" method. Again, you only have to change Piwik_Query to
And the whole thing will work :) |
@dbmz The script that you suggested outputs geoip functions in the 'internal' array like this: [ 1278 ] => geoip_database_info My piwik installation is not an extra host. it's just a site's subdirectory. |
Since I have updated PIWIK to 1.8.4 I do not see any city information in the visitors log. Any idea? |
Please make available a single always up-to-date zip file mortals can download and install without headaches form patches, updates, and so on :) It would be very nice to have the main download always point to this latest release. Thank you in advance. |
In the next 1.9 release, GeoIP will be included in Piwik by default. See #1823 |
Very good news :) thank you |
Dear all, I am using piwik 1.4 ,I have configured it according to my database. I followed these steps In my configuted piwik i am not getting any setting option and i couldnt do "Enable GeoIP plugin in Piwik. Go to Piwik > Settings > Plugins > Geoip, click Enable" one more query For the GeoIp we are using .swf or someother file?? |
Did you install the host files ? You can find them from Europe here Kinde regards Replying to rajkisho:
|
Thanks...I have sorted out that issue. Next query is as follows: I see 3 colors I want in the Piwik files..where this color configration is done ?? |
After the plugin was added to the core, the old table rows can be deleted to clean the database a bit, right? As I do not want to delete the wrong rows or just some of the rows, what exactly can I delete? |
UPDATE! GeoIP Is now available as part of Piwik Core!
Ask questions in the forums: http://forum.piwik.org/ or get some Piwik Experts to help you: http://piwik.org/consulting/ |
What about my question from yesterday about the old table rows which can be deleted from the database? |
Can I override GeoIP with custom data? For example I have an organization with many offices and subnets and I want to see those office locations in Piwik, based on my defined subnet=location data. Maxmind doesn't have these details. Or should I post this as a feature request? |
You can write a custom plugin that hooks into Tracker.saveVisitorInformation, checks whether location_ip is in your subnet and overrides the other location_* attributes of the visitor information. This ticket is not the right place for questions like this. If you want further free support, you can use our forums. If you want paid support (e.g. the development of such a plugin), you can contact services] or me via timo at piwik.org. |
GeoIp Plugin
- When installed, the plugin will detect more accurately the country of your visitors using the MaxMind database.
- The existing reports for country and continent will be replaced by the more accurate GeoIp report in your Piwik interface.
- Piwik will also detect the city of your visitors. You can see all cities by clicking on the country row in the table.
- You can apply the GeoIp data to all your previous visits and re-generate your reports, see below.
Requirements
You need at least Piwik 0.2.33 to run the GeoIp plugin.
How to install?
- [Download Piwik GeoIp Plugin](http://issues.piwik.org/attachments/5465/GeoIP.zip?format=raw)
- Unzip the plugin and copy the extracted directory “GeoIp” in the directory piwik/plugins/
- Configure the MaxMind database:
– Either download MaxMind GeoLite City or GeoIP City database from http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
Uncompress this file and copy it in plugins/GeoIP/libs/GeoLiteCity.dat
– 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
- Enable GeoIP plugin in Piwik. Go to Piwik > Settings > Plugins > Geoip, click Enable
How to apply the GeoIp to all your previous visits to fix your previous reports
You can apply GeoIP precise localization on your past data:
- run geoipUpdateRows.php script, from command line (or from the browser, but risk of timing out if your database is large)
- wait a few minutes until all your visitors data from the piwik_log_visit table have been processed.
- you now need to force Piwik to re-process all the past reports: drop all piwik_archive_\* tables in your Piwik database. Piwik will automatically create them and re-process the reports.
- You should see Visitors countries and cities in your Visitors>Location report.
Authors
- Mikael Letang
- Maciej Zawadziski
- Matthieu Aubry
- Anthon Pang
Changelog
- version 0.7: cleaned up code, compatible with Piwik 0.2.33, improved documentation
- version 0.8: fixed bug in geoIpUpdateRows.php (thanks looztra)
- version 0.9: all fields now NULLable to make sure that insert still work fine after plugin is disabled
- version 0.10: compatibility with 0.2.35 after API change in the AddWidget function
- version 0.11: fixing bug with country detection
- version 0.12: updated for auto loader
- version 0.13: Compatible with Piwik 0.6
- version 0.14:
– Fixed geoipUpdateRows script which was failing with errors. It also now checks that logged in user is Super User, and that the GeoIP plugin is enabled.
– Fixed memory leak when using visitor generator.
– Fixed .htaccess was blocking users from executing the script with the browser.
– Added .htaccess to allow to execute the script directly from the browser.
– Fixed Sparkline distinct countries
- version 0.15:
– Updated for Piwik 1.3 (refactoring for upgrade.php)
– No match for country now set to ‘xx’ (unknown)
- version 0.16:
– fix bootstrap in geoipUpdateRows.php and clean-up package
– geoipUpdateRows.php – MYSQLI compatibility
– default to disk-based search; load into memory if multiple tracking requests
- version 0.17:
– fixes from peterb & mruge
- version 0.18: compatible with Piwik 1.6
Feedback
Please leave a comment if you have any feedback, suggestion, or bug report.
Keywords: third-party-plugin
The text was updated successfully, but these errors were encountered: