邵珠庆の博客 生命只有一次,你可以用它来做些更多伟大的事情–Make the world a little better and easier

234月/151

GA User Timings – Web Tracking (ga.js) _trackTiming

var startTime = new Date().getTime();//请求前添加

var endTime = new Date().getTime();//请求成功后添加

var timeSpent = endTime - startTime;
_gaq.push(['_trackTiming', 'Pop-up Layer', 'Get AjaxData ', timeSpent, '页面URL名称', 100]);
请将红色部分进行替换~~

Setting Up User Timings

To collect user timing data, you'll need to use the _trackTiming method, which sends time data to Google Analytics.

_gaq.push([‘_trackTiming’, category, variable, time, opt_label, opt_sample]);

Where the parameters represent:

Parameter Value Required Summary
category

类别

string yes A string for categorizing all user timing variables into logical groups for easier reporting purposes. For example you might use value of jQuery if you were tracking the time it took to load that particular JavaScript library.

一个字符串进行分类的所有用户时间变量到逻辑组,便于报告的目的。例如,你可以使用jQuery,如果你跟踪它采取加载特定的JavaScript库的时间。

variable

变量

string yes A string to indicate the name of the action of the resource being tracked. For example you might use the value of JavaScript Load if you wanted to track the time it took to load the jQuery JavaScript library. Note that same variables can be used across multiple categories to track timings for an event common to these categories such as Javascript Load and Page Ready Time, etc.

一个字符串,以指示该资源的操作的名称被跟踪。例如,你可以使用,如果你想跟踪它走上加载jQuery JavaScript库时的JavaScript加载的价值。需要注意的是相同的变量可以跨多个类别被用来跟踪定时共同这些类别例如JavaScript负荷和页面就绪时间等事件

time

时间

number yes The number of milliseconds in elapsed time to report to Google Analytics. If the jQuery library took 20 milliseconds to load, then you would send the value of 20.

在经过时间的毫秒数报告给谷歌Analytics(分析)。如果jQuery库花了20毫秒加载,那么你会送20的值。

opt_label

标签

string no A string that can be used to add flexibility in visualizing user timings in the reports. Labels can also be used to focus on different sub experiments for the same category and variable combination. For example if we loaded jQuery from the Google Content Delivery Network, we would use the value ofGoogle CDN.

可用于增加灵活性在报告中可视用户定时的字符串。标签也可用于集中为同一类别和变量的组合不同的子实验。例如,如果我们加载的jQuery从谷歌的内容交付网络,我们将使用谷歌CDN的价值。

opt_sampleRate

抽样比例

number no A number to manually override the percent of visitors whose timing hits get sent to Google Analytics. The default is set at the same number as general site speed data collection and is based as a percentage of visitors. So if you wanted to track _trackTiming hits for 100% of visitors, you would use the value 100. Note that each hit counts against the general 500 hits per session limit.

一些手动覆盖游客的时机命中被发送到谷歌Analytics(分析)的百分比。缺省设定为相同数量的常规站点高速数据采集,并基于作为访问者的百分比。所以,如果你想跟踪_trackTiming命中游客100%,你会使用值100注,每命中计数对每个会话限制一般500命中。

邵珠庆推荐文章

博文加载中...

anyShare分享到:

喜欢这个文章吗?

考虑订阅我们的RSS Feed吧!

发布在 邵珠庆

评论 (1) 引用 (0)
  1. 今天碰巧查找这个用户计时跟踪代码,百度上各种搜索都没有,然后谷歌搜索英文单词,竟然看到博主这篇文章了。 佩服。。 博客已收藏,有时间回来仔细看看博主的其它文章。


Leave a comment

*

还没有引用.