Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • brianfohn

    (@brianfohn)

    WPEngine Employee

    Hi there Aaron, thanks for contributing!

    brianfohn

    (@brianfohn)

    WPEngine Employee

    Hey there Dunskii, thanks for reaching out!

    When leveraging GeoTarget to determine the longitude/latitude of a visitor, it is definitely possible to see ‘fuzzy’ or inaccurate location data due to the inherent limitations of IP based geolocation. GeoTarget leverages the Maxmind database in order to lookup location data based on visitor IP.

    While Maxmind and other IP based geolocation databases aim to be as accurate as possible, it can be difficult to accurately assign location data to IP addresses down to the longitude/latitude level. The general rule of thumb with IP based geolocation is that location data is most accurate the higher level you use it. So for example, country, region, or city location data is more likely to be accurate than more specific data such as longitude/latitude.

    If highly accurate longitude/latitude data is absolutely essential to your use case, you may want to also consider using browser side geolocation, since a visitors browser can potentially supply much more specific location information based on things like device GPS.

    I hope this helps point you in the right direction!

    • This reply was modified 6 years, 10 months ago by brianfohn.
    brianfohn

    (@brianfohn)

    WPEngine Employee

    Hey philmccollam,

    I’m glad to hear that you’re making progress with you code.
    With regards to troubleshooting the redirect loops you are seeing, one way to isolate whether the domain redirect and http => https redirects are affecting this would be to test this behavior with each of those redirects disabled.
    I hope this helps point you in the right direction.

    I also want to mention that if you aren’t already working with a development service or an agency, you may want to look into using Codeable’s services, as they have many PHP and WordPress developers who may be able to assist with your project directly.
    Also depending on the scope and scale of your project, our network of consultants could be an ideal resource as well.

    brianfohn

    (@brianfohn)

    WPEngine Employee

    Hi philmccollam,
    Thanks for reaching out!

    If the goal is to redirect based on Country Code using GeoTarget, you should ensure that the HTTP_GEOIP_COUNTRY_CODE environment variable is being properly utilized in your PHP code.

    Here’s an example function from our documentation that could be used as a model to help you reach your goal:

    function country_geo_redirect() {
    $country = getenv('HTTP_GEOIP_COUNTRY_CODE');
    if ( $country == "US" ) {
    wp_redirect( 'https://us.domain.com';, 301 );
    exit; }
    else if ( $country == "FR" ) {
    wp_redirect( 'https://fr.domain.com';, 301 );
    exit; }
    }
    add_action('init', country_geo_redirect');
    brianfohn

    (@brianfohn)

    WPEngine Employee

    Hey there, thank you for bringing this to our attention!
    We will be releasing an update to the plugin soon to resolve these kinds of issues, in the meantime adding this to your functions.php file should be able to resolve this.

    <?php
    /**
     * Filters the WP Engine GeoIP location names.
     * Removes any slashes in the names.
     *
     * @param  array $geos GeoIP-identified location names.
     * @return array       GeoIP-identified location names without slashes.
     */
    function myprefix_remove_geoip_slashes( $geos ) {
    	return wp_unslash( $geos );
    }
    add_filter( 'geoip_location_values', 'myprefix_remove_geoip_slashes' );
    • This reply was modified 7 years, 1 month ago by brianfohn.
Viewing 5 replies - 1 through 5 (of 5 total)