How do i track the visitor's country and redirect them to appropriate sites?

前端 未结 5 430
深忆病人
深忆病人 2021-02-04 14:16

I want to track the country of the visitors and then redirect them to appropriate subdomains of my site like what google does...

And upto what extent i can rely on the d

5条回答
  •  你的背包
    2021-02-04 14:40

    One version is that you can use your service providers' ip address and hence redirect it with Javascript as follows;

    $.get("https://ipinfo.io", function(response) {
       if(response.country=="GB"){
          window.location.replace("http://stackoverflow.com");
       }
    }, "jsonp");
    

提交回复
热议问题