1

For incorporating Google Analytics into my website (a single page application with the same navbar and footer but different view on each page) built using AngularJS, do I simply just put the tracking code in the index.html file to track every page?

I've done that but it doesn't seem like I'm able to see the views that I'm getting on other pages besides my home page. Some insight into whether I'm doing it right would help a lot!

user3226932
  • 2,042
  • 6
  • 39
  • 76

1 Answers1

2

Google Analytics javascript count every time a page is loaded or reloaded. In an AngularJS single page application, the index page loads only once. To get over the page reload requirement of google analytics, you will have to hook $viewContentLoaded or $routeChangeSuccess listeners. For a simplistic solution, this answer could help you.

Tracking Google Analytics Page Views with Angular.js

If you would like to explore more advanced implementation, the following two options may be interesting.

https://luisfarzati.github.io/angulartics/

https://github.com/revolunet/angular-google-analytics

Community
  • 1
  • 1
user850323
  • 188
  • 8
  • Got it kind of working but for some reason there's a tracking error, would appreciate it if you could check out another question I have http://stackoverflow.com/questions/34538042/google-analytics-page-views-are-being-incremented-incorrectly-for-each-page-chan – user3226932 Dec 30 '15 at 22:13