What does Cloudflare IP Geolocation do?

You can enable IP Geolocation to have Cloudflare geolocate visitors to your website and pass the country code to you in ISO 3166-1 Alpha 2 format. 

You will find the IP Geolocation option under the 'Network' section of the dashboard.

The option for IP geolocation will be found near the bottom of the page:

Once enabled, we will then add a header called "CF-IPCountry" to all requests we make to your website. Here are a couple of examples of how to access/store this value:

$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"]; // to access in PHP

$country_code = $ENV{"HTTP_CF_IPCOUNTRY"}; # to access in Perl 

Cloudflare includes this information for both IPv4 and IPv6 addresses. Currently, the IPv4 information is more robust, but we expect the IPv6 data to improve rapidly.

 Note: XX means there is no country data. T1 is a non-standard country code used for the Tor network.


Still not finding what you need?

The Cloudflare team is here to help. 95% of questions can be answered using the search tool, but if you can’t find what you need, submit a support request.

Powered by Zendesk