Geo Location

Retrieve geo location information from visitors IP address

Back to Geo Location Support

pranav.slinfy27081
pranav.slinfy27081

I am try to implement geolocation plugin functionality to get the location of visitor please guide me how can i do this?

gatis.pelcers
gatis.pelcers

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";
}
j_depad1326212
j_depad1326212

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");
     }   
}
dbelliot
dbelliot

Just use the translate plugin by RainLab. It does exactly what you want. Automatically.

1-4 of 4