Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Eyal Fitoussi

    (@ninjew)

    Hello @wlsfh,

    Just wondering if it is possible to avoid a full page refresh upon visitors accept/allow to share their location.

    I was wanting to load the front page, including the geo targeted map, in one go, rather than in two steps.

    Is it anyway possible?

    That is not possible at the moment.

    The browser’s navigator function that GEO my WP depends on when getting the current location is trigger via the client-side. Which means only after the page was loaded.

    So the page must first load, then the navigator is triggered via JavaScript and saves the user’s location in cookies. The page will then reload and use those cookies to display locations nearby the user’s location.

    It should be possible to disable the page reload using a filter, but that means that the map will show locations based on the user’s location only after the user reloads the page.

    I was also wondering whether it’s possible to integrate with CloudFlare IP

    Based on the pages you mentioned above I can see that you can pull the country using CloudFlare IP. Can you also pull the coordinates?

    Thread Starter wlsfh

    (@wlsfh)

    Hi Eyal,

    Thanks for your answer, much appreciated.

    No we don’t pull GEO coordinates from CloudFlare yet; mine was just a pure speculation on how it would have been possibile via integrating CF coordinates with Geo My Wp.

    Apart from this, our aim was to speed the front page by using cache.
    Cache and geotagging are not friends as you know.

    One way was to use Page Cache Fragmentation and we tried using W3 Total Cache, but it seems it won’t work for god knows that reason. For your info, we set this up in header.php

    <!–mfunc FRAGMENT_CACHING –>
    echo do_shortcode(‘[gmw map=”2″]’);
    echo do_shortcode(‘[gmw search_results=”2″]’);
    <!–/mfunc FRAGMENT_CACHING –>

    So to tell W3TC to cache everything but the shortcode, but unfortunately did not work.

    One solution, suggested by W3TC, is to use ajax to load the maps dynamically to bypass the cache.
    I know you have some paid extension using Ajax; do you think we could solve the problem with i.e. Global Maps ?

    If so, I need probably to ask you more.

    Cheers

    Plugin Author Eyal Fitoussi

    (@ninjew)

    @wlsfh,

    1. If you are able to pull the coordinates via Cloudflare, then it would most likely be possible to use those instead of using GEO my WP’s locations. There is a filter that you could use to pass the coordinates from CloudFlare into GEO my WP’s search form before displaying the results.
    2. What exactly is the issue with the cache? The user’s current location isn’t changing and gets stuck in the cache?
    Thread Starter wlsfh

    (@wlsfh)

    Hi eyal,

    Thanks for your answer.

    1. What filter do you exactly mean? This could be our solution.
    2. We use Geo my WP right in the front page.
    The issue (if you call it issue) is when users land on the front page, the page is been cached. After they ‘give consent’ to track their location, the page refreshes, but due to the cache the map does not refreshes to fit users location’s (we set a radius of 250k).

    Thread Starter wlsfh

    (@wlsfh)

    Hi Eyal,

    After following your hint above 1), we are trying to optimize the logic of how we perform geo tracking on our website. In particular, we would like to avoid ‘refreshing’ the page after visitors accept to have their location tracked (mainly for caching issues, but also to avoid repainting the fron page).

    By using Cloudflare Geo IP we may be able to track visitors location beforehand, thus using:

    $country_code = $_SERVER[“HTTP_CF_IPCOUNTRY”]; //from cloudflare headers

    What we miss though, is how to tell Geo my WP to use this variable to resolve visitors location (therefore avoid using ‘auto locate’ cookie).

    Could you give us some extra info please?

    Thank you for your help!

    Plugin Author Eyal Fitoussi

    (@ninjew)

    @wlsfh,

    The script below should use the country provided by Cloudflare, if any, and filter the search results and show posts from that country only.

    
    function gmw_pt_results_based_on_cloudflare( $form ) {
    
    	$form['page_load_results']['country_filter'] = ! empty( $_SERVER['HTTP_CF_IPCOUNTRY'] ) ? $_SERVER['HTTP_CF_IPCOUNTRY'] : '';
    
    	return $form;
    }
    add_filter( 'gmw_pt_default_form_values', 'gmw_pt_results_based_on_cloudflare', 50 );
    

    You need to make sure that in the Page Load Results tab of the form editor, the “Visitor’s Current Location Filter” checkbox is unchecked and the “Address filter” text box is blank.

    Let me know how it goes.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Avoid full page refresh after users allow location’ is closed to new replies.