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.
I can see two options:
1) trackevent('Navigation', 'View title');
2) trackevent('Navigation', 'Click', '', 'View title');
trackevent('Navigation', 'Redirect', '', 'View title');
Of course one can do either, but which option is best when it es to analyzing the data in Google Analytics?
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.
I can see two options:
1) trackevent('Navigation', 'View title');
2) trackevent('Navigation', 'Click', '', 'View title');
trackevent('Navigation', 'Redirect', '', 'View title');
Of course one can do either, but which option is best when it es to analyzing the data in Google Analytics?
Share Improve this question edited Jun 1, 2013 at 14:17 Per Quested Aronsson asked Jun 1, 2013 at 8:05 Per Quested AronssonPer Quested Aronsson 12.1k8 gold badges57 silver badges77 bronze badges 3- I found the answers in this excellent article: The Complete Google Analytics Event Tracking Guide Plus 10 Amazing Examples: – Per Quested Aronsson Commented Jun 1, 2013 at 14:16
- Have you considered just pushing trackPageviews of virtual pages? Like modeling your application as if it had different pages (which, in effect, it does) – vly Commented Jun 3, 2013 at 0:31
- I have considered it, but decided to go for events because 1) I would like to separate pageview-by-click from pageview-by-redirect and 2) I track quite a few other events in the app, so I thought it would be simpler to have it all as events. What are the advantages of using trackPageview instead? – Per Quested Aronsson Commented Jun 4, 2013 at 6:11
2 Answers
Reset to default 9The Angulartics plugin provides web analytics for AngularJS applications. There is an example application which uses Google Analytics.
It supports:
- page tracking
- event tracking
- scroll tracking
I would remend looking for a specific plugins for your routing framework. I am using knockout for MVVM and sammy.js for routing purpose. I found it as an excellent tool for routing and based on my understanding it is under active development/maintenance.
Sammy developer created a pluging for interracting with google analytics which handles all the work for you. It is pretty easy to use:
$.sammy(function() { with(this) {
use(Sammy.GoogleAnalytics)
...
}});