Hello Jonathan,
I would recommend
against using IP geolocation for GDPR compliance for two reasons:
- The most important is the legal aspect. All citizens of the European Union get GDPR protection no matter where they are currently located. A German citizen in New York gets the same GDPR protections as a German citizen in Berlin.
- Even if legality wasn't an issue, geolocation services offer an accuracy ranging from 95% (free version) to 99% (paid version). That's a lot of people whose location is reported wrong. Things get even more complicated when people are on planes and ships; in those cases the accuracy is exactly 0%.
If you really want to shoot yourself in the foot you can use the MaxMind integration services provided by
our GeoIP plugin. The plugin automatically loads the AkeebaGeoipProvider class (found in plugins/system/akgeoip/lib/akgeoip.php on your site). You can instantiate an object of that class and call getCountryRecord.
Quick example:
if (!defined('FOF30_INCLUDED') && !@include_once(JPATH_LIBRARIES . '/fof30/include.php'))
{
die('You need to have the Akeeba Framework-on-Framework (FOF) 3 package installed on your site to use this component. Please visit https://www.akeeba.com/download/fof3.html to download it and install it on your site.');
return;
}
// e.g. 2.84.1.2
$ip = FOF30\Utils\Ip::getIp();
$geoIP = new AkeebaGeoipProvider();
// e.g. 'GR'
$countryCode = $geoIP->getCountryCode($ip);
Nicholas K. Dionysopoulos
Lead Developer and Director
🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!