源码:
<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-548031-10");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
} catch(err) {}</script>
解释:
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
判断当前协议是不是https,是gaJsHost ="https://ssl.",否gaJsHost ="http://www."
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
对"%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"进行解码后,写道html页面上注:解码就是通过找到形式为 %xx 和 %uxxxx 的字符序列(x 表示十六进制的数字),用 Unicode 字符 \u00xx 和 \uxxxx 替换这样的字符序列进行解码
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-548031-10");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
} catch(err) {}</script>
动态加载js文件源代码
附:
google analytics 老版本的ga.js,是流量统计工具var pageTracker = _gat._getTracker("UA-8946782-1");google analytics账户信息pageTracker._setDomainName(".btduowei.com");域名,跨域pageTracker._setAllowLinker(true);参数值pageTracker._setAllowHash(false);参数值pageTracker._addOrganic("youdao",'q');有道查询关键词字段pageTracker._addOrganic("soso",'w');soso查询关键词字段pageTracker._addOrganic("sogou",'query');sogou查询关键词字段pageTracker._addOrganic("gougou",'search');gougou查询关键词字段pageTracker._trackPageview();跟踪流量统计