← Back to Geo Location Support
I am try to implement geolocation plugin functionality to get the location of visitor please guide me how can i do this?
Hi, Have you read the "Documentation" section here: https://octobercms.com/plugin/raccoon-geolocation ?
First you have to correctly set up one of two available geo services (see "Screenshoots" section for available settings).
See code block below for actual usage example in PHP code. It retrieves visitor's location and performs some logic based on visitor's country ISO code:
use Raccoon\GeoLocation\Facades\Geo;
$geoLocation = Geo::getLocation($ipAddress);
if ($geoLocation->countryCode === 'US') {
echo "do something";
}
Hi Gatis Pelcers,
I am new in this world. I want to use your plugin for redirections inside my web page. For example if a person from US wants to enter to my page (hello.com) I want that automatlicly It takes him to hello.com/en and if a spanish person want to enter too it will reedirects him to hello.com/es.
Right now I have something like this:
use Raccoon\GeoLocation\Facades\Geo;
function getFacadeAccessor() {
$geoLocation = Geo::getLocation($ipAddress);
if ($geoLocation->countryCode === 'US') {
header("Location: https://www.hello.com/en");
} else {
header("Location: https://www.hello.com/es");
}
}
1-4 of 4