存档

‘开放平台’ 分类的存档

用Google Analytics跟踪用户行为来优化网站

2010年3月12日

Google Analytics(谷歌分析)为我们提供了强大的网站统计功能,其中Custom Reports(自定义报告)功能更是为我们扩展统计功能提供了方便。在这里我们探讨一下通过自定义报告功能跟踪用户行为的方法。

Google Analytics的统计代码分为标准统计和异步统计两种,因此我们分开讨论。先看看两种基本的统计代码:

标准统计
<script type=”text/javascript”>
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(“%3Cscript src=’” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script>
<script type=”text/javascript”>
try{
var pageTracker = _gat._getTracker(“UA-xxxxxx-x”);
pageTracker._trackPageview();
} catch(err) {}</script>
异步统计
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);(function() {
var ga = document.createElement(’script’);
ga.src = (‘https:’ == document.location.protocol ?
‘https://ssl’ : ‘http://www’) +
‘.google-analytics.com/ga.js’;
ga.setAttribute(‘async’, ‘true’);
document.documentElement.firstChild.appendChild(ga);
})();

开放平台 , , ,

Google地图API服务器拒绝了您的请求

2010年1月5日

Google地图注册密钥以后,本地测试没问题,加入正式域名网站以后出现下列提示:

google地图API服务器拒绝了您的请求。请求中指定的”sensor”参数必须设置为”true”或”false”

解决方法如下:
申请Google地图密钥后会得到下面一段代码:

// Note: you will need to replace the sensor parameter below with either an explicit true or false value.
<script src=”http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true_or_false&amp;key=ABQIAAAAXQDW0GZOX6MYzV1c6iSyOBSofguSEDyTvDvt3HTgy0JmTsYTZhRWZn_w7gRJCH-2dr23he4MUlP2iQ” type=”text/javascript”></script>

注意把上面的sensor=true_or_false 改成 sensor=true 或者 sensor=false 就可以了 。

阅读全文…

开放平台 , ,

Google Maps API用法教程

2009年12月29日

在过去的一年中,在线地图的发展是相当巨大,我们可以看到在线地图的极有价值的信息和其能力。这其中,最有名气的自然是Google Maps。. Google Maps由一个相当强大的开发引擎并也有一个很大的社区提示支持。

Google 允许各种web masters 通过Google Maps API来增加或自定义他们站点特定的地图,你可能从这里取得Google API key 。一个地图 API key只对一个“目录”或域有效。key绑定了你的域名,你要在网站上放地图,需要有对应的key,否则拒绝读取地图数据,在本地测试可以不用key。当然,你可以申请多个API key。

阅读全文…

开放平台 ,