Brent W
Well-known member
Cloudflare seems to include a header with every request that holds the visitors location. Would it be possible to create a template conditional based off this header?
What is IP Geolocation?
CloudFlare can geolocate visitors to your website and pass the country code on to you. Once enabled, we will then add an HTTP header named "CF-IPCountry" to all requests we make to your website.
Note: CloudFlare includes this information for both IPv4 and IPv6 addresses.
Would make it easy to target advertisements to specific countries without the use of robust ad server programs or additional queries to 3rd party services.
Here is the code example. Looks pretty straight forward.
What is IP Geolocation?
CloudFlare can geolocate visitors to your website and pass the country code on to you. Once enabled, we will then add an HTTP header named "CF-IPCountry" to all requests we make to your website.
Note: CloudFlare includes this information for both IPv4 and IPv6 addresses.
Would make it easy to target advertisements to specific countries without the use of robust ad server programs or additional queries to 3rd party services.
Here is the code example. Looks pretty straight forward.
PHP:
$country_code = $_SERVER["HTTP_CF_IPCOUNTRY"];
Last edited: