我的页面使用 GA 为自己提供统计数据。我稍后可以看到访问我网站最多的国家/地区。
有什么办法可以在客户端获取客户的国家/地区吗?如果用户不是来自我的国家,我想向她显示一条通知。
您无法使用 GA 在浏览器中访问该信息。
如果您想在浏览器中访问该信息
尝试在支持地理定位的浏览器中进行地理定位。
spec.
http://dev.w3.org/geo/api/spec-source.html http://dev.w3.org/geo/api/spec-source.html
demo:
http://html5demos.com/geo http://html5demos.com/geo
sample:
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
});
}
然后您可以使用以下命令访问完整地址谷歌反向地理编码 https://developers.google.com/maps/documentation/geocoding/#ReverseGeocoding in 格式化地址 filed
{
"status": "OK",
"results": [ {
"types": street_address,
"formatted_address": "275-291 Bedford Ave, Brooklyn, NY 11211, USA",
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)