AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

1.7K members online now
1.7K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
Guide Me

Google Analytics for AngularJS SPA (Single Page Analytics) using Autotrack

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I'm trying to implement Google Analytics for AngularJS single page application. For this, I'm using Autotrack and UrlChangeTracker for which the Google Analytics should also display virtual page views which the user views in AngularJS SPA. But, all I'm getting in the Google Analytics Real Time overview is just the index page view.Google Analytics Real time overview


The Google Analytics code snippet:


<script>||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
        ga('create', 'UA-XXXXXXX-1', 'auto');
        ga('require', 'urlChangeTracker', {
        shouldTrackUrlChange: function(newPath, oldPath) {
            newPath = newPath.split('?')[0];
            oldPath = oldPath.split('?')[0];
            return newPath != oldPath;
        ga('send', 'pageview');
        <script async src=''></script>
        <script async src=""></script>

Is there anyway i can implement the Google Analytics on SPA.

I was able to see the virtual page views in Google Analytics previously, but not now.

Google Analytics for AngularJS SPA (Single Page Analytics) using Autotrack

[ Edited ]
Participant ✭ ✭ ✭
# 2
Participant ✭ ✭ ✭



I would recommend reading a blog written by Simo Ahava. Really great stuff.


Here you can find a couple of articles how to implement GA on SPA through GTM:





Lunametrics has written a great article about that as well:


Hope this helps. Let us know how it goes.