Reputation: 9266
How do I configure Google Universal Analytics with AngularJS and instantly see some test data from my local test environment?
The current code:
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXX-X', { // I have my actual UA id here
cookieDomain: 'none'
});
</script>
</head>
I also have this one:
$rootScope.$on('$routeChangeStart', function() {
ga('set', 'page', $location.url());
});
In the Real-time section in Google Analytics Dashboard i see '0 active visitors'.
Upvotes: 0
Views: 885
Reputation: 32760
You set a page url but you don't seem to have a call to the send function
ga('send', 'pageview');
"set" merely sets fields (you can do this via a configuration object as the third parameter to the send pageview, too), you need "send" to, well, send them.
Upvotes: 2