12

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 comes to analyzing the data in Google Analytics?

Per Quested Aronsson
  • 11,380
  • 8
  • 54
  • 76
  • 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 Jun 03 '13 at 00: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 Jun 04 '13 at 06:11
  • I found the answers in this excellent article: [The Complete Google Analytics Event Tracking Guide Plus 10 Amazing Examples](http://www.koozai.com/blog/analytics/the-complete-google-analytics-event-tracking-guide-plus-10-amazing-examples/): – Per Quested Aronsson Jun 01 '13 at 14:16

2 Answers2

9

The 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
ndequeker
  • 7,932
  • 7
  • 61
  • 93
0

I would recommend 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)

  ...
}});
Salvador Dali
  • 214,103
  • 147
  • 703
  • 753