1. Inicio
  2. Base de conocimientos
  3. ThirstyAffiliates (versión gratuita)
  4. Cómo rastrear las estadísticas de Geo IP cuando Cloudflare está activado
  1. Inicio
  2. Base de conocimientos
  3. ThirstyAffiliates Pro
  4. Cómo rastrear las estadísticas de Geo IP cuando Cloudflare está activado

Cómo rastrear las estadísticas de Geo IP cuando Cloudflare está activado

Cloudflare enmascara la dirección IP del usuario y la traslada a otra cabecera HTTP.

To make it compatible with ThirstyAffiliate’s stats collection module you will need to add the following snippet of code to your functions.php file or a drop-in plugin.

function ta_cloudflare_ip_compatibilidad( $ip ) {
    if ( ! empty( $_SERVER['HTTP_CF_CONNECTING_IP'] ) )
            $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
    return $ip;
}
add_filter( 'ta_get_user_ip_address' , 'ta_cloudflare_ip_compatibility' , 10 , 1 );

Esta función se añadirá a ThirstyAffiliates en el futuro.

 

Añada el siguiente fragmento de código a su archivo functions.php o a un complemento del módulo Geolocations cuando redirija:

function get_proper_ip_from_cf_for_ta_geo($address) {
	if(isset($_SERVER['HTTP_CF_CONNECTING_IP']) && !empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
		$address = $_SERVER['HTTP_CF_CONNECTING_IP'];
	}
	return $address;
}
add_filter('tap_geolocation_client_ip', 'get_proper_ip_from_cf_for_ta_geo');

 

¿Le ha resultado útil este artículo?

Artículos relacionados

¿Necesita ayuda?

¿No encuentra la respuesta que busca?
Contacto