如何使用Google Analytics(分析)确定客户所在的国家/地区? [英] How to determine client's country using Google Analytics?
问题描述
我的页面使用GA为自己提供统计信息.以后我可以看到访问量最大的国家/地区.
My page uses GA to provide myself with statistics. I can later see countries that were most visiting my site.
有什么办法可以使客户所在的国家/地区在客户那边吗?如果她不是我的国家/地区,我想向用户显示通知.
Are there any way to get client's country at the client-side? I would like to show user a notification if she is not from my country.
推荐答案
您无法使用GA在浏览器中访问该信息.
You don't have access to that information in the browser using GA.
如果要在浏览器中访问该信息在支持该功能的浏览器中尝试地理定位.
If you want to access that information in the browser Try geolocation in browsers whom support it.
规格 http://dev.w3.org/geo/api/spec-source.html
样本:
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
});
}
然后您可以使用 google ReverseGeocoding 访问完整地址已提交 formatted_address
And then you can access to the complete address using google ReverseGeocoding in formatted_address filed
{
"status": "OK",
"results": [ {
"types": street_address,
"formatted_address": "275-291 Bedford Ave, Brooklyn, NY 11211, USA",
这篇关于如何使用Google Analytics(分析)确定客户所在的国家/地区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!