Geolocation not forwarded anymore..?

I am using ThirstyAffiliate plugin for managing my affiliate links and last week I noticed that only a couple of countries were listed. So I figured out that they were probably the Cloudflare datacenters.

After doing something research I noticed we needed to use the $_SERVER[‘HTTP_CF_IPCOUNTRY’] header to get the visitors’ original IP address. So I made the necessary changes, but unfortunately, it didn’t seem to work.

But I am also using Affluent to track my affiliate income, and I just noticed that they were also unable to track any geolocation. It all worked fine until October 26th, from then on neither (Affluent or ThirstyAffiliate) are able to track the geolocation.

Affluent isn’t a WordPress plugin, it’s just a dashboard that read-outs different advertisers through there API.

So I must have screwed something up in Cloudflare, but what… The setting " IP Geolocation" in the Network tab is still turned on. I have no idea what else good causes this problem.

Any thoughts?

Save the following line in a new .php file on your server and check its output.

<?php var_dump($_SERVER['HTTP_CF_IPCOUNTRY']);

If it shows the country code, the header is properly received and the issue will be somewhere else on your site.

I simply got the wrong header, following is working:

   if ( ! empty( $_SERVER['HTTP_CF_CONNECTING_IP'] ) )
        $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
    elseif ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) )
        $ip = $_SERVER['HTTP_CLIENT_IP'];

This topic was automatically closed after 14 days. New replies are no longer allowed.