1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

IP-GeoLocation with Cloudflare

Discussion in 'Other Languages' started by roadhamster, May 3, 2015.

  1. roadhamster

    roadhamster Regular Member

    Joined:
    Mar 12, 2012
    Messages:
    340
    Likes Received:
    244
    Can't find a post about it, so here it is.
    Cloudflare supports IP-GeoLocation. For a lot of people asking how to get the country through the visitors IP, for redirecting purposes based on country of origin, if you have your site on Cloudflare you can use Cloudflare's IP-GeoLocation. It's enabled by default in your CF's dashboard, and it's available from the Free plan.

    CF_IPGEO.jpg

    How to get it via PHP: CF_IPGEO_php.jpg
    $geo will be the will be your 2 character country-code.

    Due to posting custom tags error, I created an image for the code, sorry for that.


    Nice feature, isn't it?

    PS: mods, could you check why we can't include tags in our code? Got the following error while trying to submit post: You do not have permission to create tags. You may only use existing tags.
     
    Last edited: May 3, 2015
  2. towelfox

    towelfox Junior Member

    Joined:
    Jan 11, 2012
    Messages:
    173
    Likes Received:
    55
    Yeah it's useful I use it when I'm targeting country specific. It's no good for city and state level but I use another service when I need that, which for what I do is rare.