Repository navigation
Description
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
Activity
anonymous-matomo-user commentedon Apr 8, 2009
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…
mattab commentedon Apr 14, 2009
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?
anonymous-matomo-user commentedon May 26, 2009
@rembrand:
You're using mod_geoip, right? Here's an excerpt from my apache conf:
<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPEnableUTF8 On
GeoIPOutput Env
GeoIPDBFile /path/to/GeoLiteCity.dat MemoryCache
# for mod_proxy's X-Forwarded-For
GeoIPScanProxyHeaders On
</IfModule>
Furthermore, check permissions on GeoLiteCity.dat, try chown <apacheuser> /path/to/GeoLiteCity.dat
anonymous-matomo-user commentedon May 27, 2009
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...
anonymous-matomo-user commentedon Jun 15, 2009
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?
mattab commentedon Jun 15, 2009
duylaiabc, can you please post a screenshot of how the reporting look like?
anonymous-matomo-user commentedon Jun 18, 2009
it tried to get location_geoip_latitude, location_geoip_longitude from api.
I added this two columns to archiveDayAggregateVisits sql query and added
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.
Has anybody an idea why?
anonymous-matomo-user commentedon Jul 18, 2009
for people with limited memory you can replace
into
in GeoIP.php
anonymous-matomo-user commentedon Aug 25, 2009
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.
anonymous-matomo-user commentedon Nov 24, 2009
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)...
mattab commentedon Dec 9, 2009
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.
anonymous-matomo-user commentedon Jan 12, 2010
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.
anonymous-matomo-user commentedon Jan 19, 2010
I have all the time the "unknown" problem and sometimes "UserCountry_country_--" - but most of the time the country-detection works fine.
I tried everything :(
Same with o.5.1 - so I installad a complete new 0.5.4 with the actual GeoIP from this page and downloaded a new database-file. I followed the instruction one by one. I am sure everything is in the right directory.
Has someone some steps I could try?
anonymous-matomo-user commentedon Jan 24, 2010
Replying to anamela:
mmh. this is not realy working for me.
and instead of cities i see all the time "Unknown"
:-(
anonymous-matomo-user commentedon Jan 25, 2010
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.
158 remaining items
mattab commentedon Oct 3, 2012
In the next 1.9 release, GeoIP will be included in Piwik by default. See #1823
anonymous-matomo-user commentedon Oct 5, 2012
Very good news :) thank you
anonymous-matomo-user commentedon Oct 29, 2012
Dear all,
I am using piwik 1.4 ,I have configured it according to my database.
As of now i get the visitor information from countries only.
I want to narrow it down to state and cities and so on....!
I followed these steps
1.Download Piwik GeoIp Plugin
2.Unzip the plugin and copy the extracted directory "GeoIp" in the directory piwik/plugins/
Configure the MaxMind database:
3. 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
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
How are we using the map here??
Is it a .swf file and Js is interactig with it OR something else ??
For the GeoIp we are using .swf or someother file??
anonymous-matomo-user commentedon Oct 29, 2012
Did you install the host files ?
You can find them from Europe here
http://www.hosteurope-infos.de/phpinfo.php
Kinde regards
Gavekort
Replying to rajkisho:
anonymous-matomo-user commentedon Nov 1, 2012
Thanks...I have sorted out that issue.
Next query is as follows:
When i go to ,Visitors->Locations
I see 3 colors
Red for the country having highest numberofvisits
Dark Yello for the country having second highest numberofvisits
yello for others....
I want in the Piwik files..where this color configration is done ??
anonymous-matomo-user commentedon Nov 14, 2012
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?
mattab commentedon Nov 14, 2012
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/
anonymous-matomo-user commentedon Nov 15, 2012
What about my question from yesterday about the old table rows which can be deleted from the database?
anonymous-matomo-user commentedon Feb 11, 2014
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?
timo-bes commentedon Feb 11, 2014
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.