ExpressionEngine 7.5 has been Released! Learn More!
Get geo information about your site visitors by their IPs.
With this add-on, you can enable the country information tags in the template. You can also lookup geo information about any specific IPs. You can even use the GB IP to Nation service in your own add-on.
MUST HAVE a valid api key from RapidAPI:// IP Geo Location. After subscription, go to My Apps > {YOUR_APPLICATION} > Security. Please also check the limit around rate/request.
I’m currently supporting this API because they answered my email the fastest. Please let me know if you have any other APIs that you’d like to tap into and I’ll consider adding support to it.
In templates, you will unlock the following geo information tags:
- {gb_ip_to_nation:country}
- {gb_ip_to_nation:country_code}
- {gb_ip_to_nation:flag}
- {gb_ip_to_nation:phone_code}
- {gb_ip_to_nation:currency}
- {gb_ip_to_nation:currency_code}
- {gb_ip_to_nation:timezone}
- {gb_ip_to_nation:timezone_code}
- {gb_ip_to_nation:is_daylight_saving}
(bool)
{if gb_ip_to_nation:country == 'Canada'}
Awesome!
{/if}
<img src="{gb_ip_to_nation:flag}" alt="National flag of: {gb_ip_to_nation:country}"/>
You can also get information about a specific IP, like
{exp:gb_ip_to_nation:get_ip_info ip="IP_GOES_HERE" prefix="gb_ip"}
The national flag of {gb_ip:country} is {gb_ip:flag}, and the currency is {gb_ip:currency_code}.
{/exp:gb_ip_to_nation:get_ip_info}
If the IP information is not found, an error message will be displayed.
IMPORTANT if you only have the free basic plan, this will not work because of the rate limit (one request per second).
You can use the service like this in your own add-on
$ipService = ee('gb_ip_to_nation:IP2Nation');
if ($ipService->initialize()) {
$info = $ipService->get(IP_GOES_HERE);
}
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.