javascript 单页 Web 应用程序中的 Google Analytics 跟踪事件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16870551/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Google Analytics trackevent in single-page web app
提问by Per Quested Aronsson
What is the best (most practical) way to use Google Analytics trackevent for tracking "pageviews" in a single-page web app? trackevent takes four arguments: CATEGORY, ACTION, LABEL, VALUE. The last two are optional. Which field should I use for the view title? A "view" in a single-page web app corresponds to a page in a normal web app.
在单页网络应用程序中使用 Google Analytics trackevent 跟踪“综合浏览量”的最佳(最实用)方法是什么?trackevent 有四个参数:CATEGORY、ACTION、LABEL、VALUE。最后两个是可选的。我应该为视图标题使用哪个字段?单页 Web 应用程序中的“视图”对应于普通 Web 应用程序中的页面。
I can see two options:
我可以看到两个选项:
1) trackevent('Navigation', 'View title');
2) trackevent('Navigation', 'Click', '', 'View title');
trackevent('Navigation', 'Redirect', '', 'View title');
Of course one cando either, but which option is best when it comes to analyzing the data in Google Analytics?
当然,人们可以做下去,但哪个选项是最好的,当谈到在分析谷歌Analytics(分析)数据?
回答by ndequeker
The Angularticsplugin provides web analytics for AngularJS applications. There is an example applicationwhich uses Google Analytics.
该Angulartics插件提供了AngularJS应用网络分析。有一个使用 Google Analytics的示例应用程序。
It supports:
它支持:
- page tracking
- event tracking
- scroll tracking
- 页面跟踪
- 事件追踪
- 滚动跟踪
回答by Salvador Dali
I would recommend looking for a specific plugins for your routing framework. I am using knockout for MVVM and sammy.jsfor routing purpose. I found it as an excellent tool for routing and based on my understanding it is under active development/maintenance.
我建议为您的路由框架寻找特定的插件。我将淘汰赛用于 MVVM 和sammy.js用于路由目的。我发现它是一个出色的路由工具,根据我的理解,它正在积极开发/维护中。
Sammy developer created a plugingfor interracting with google analytics which handles all the work for you. It is pretty easy to use:
Sammy 开发人员创建了一个插件,用于与 google 分析交互,它可以为您处理所有工作。使用起来非常简单:
$.sammy(function() { with(this) {
use(Sammy.GoogleAnalytics)
...
}});

