lundi 26 septembre 2016

Redirect users to another page when they are not browsing from Spain

Thanks for your help. I am experimenting some trouble when I try to redirect users based on their location through Freegeoip.

May be for you is simple but i can´t get it work, the behaivour should be:

All visitors go to the spanish website www.theWeb.es, but those who browser from out of Spain should be redirected to the international page http://ift.tt/2cPgEgQ.

Code:

<script>
     jQuery.ajax( { url: 'http://ift.tt/2ddkRic',
    type: 'POST',  
    dataType: 'jsonp',  
    success: function(location) {
        if (location.country_code === 'ES') {
        // Do nothing because the user is already in the spanish Store.
        else {
        // if the user is not in Spain the send him to the international store.
          window.top.location.href = 'http://ift.tt/2cPeduY';
         }
    } }}); 
    </script>

Thanks for your time.




Aucun commentaire:

Enregistrer un commentaire