I'm trying to set up the new google analytics tag for my angularjs website.
I basically added this to my index.html:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GOOGLE-ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GOOGLE-ID'); //remove in order to avoid sending hits on index twice
</script>
This is my script.js:
var app = angular.module('app', ['plangular','ngRoute', 'ngSanitize', 'slick', 'chart.js', 'ngMeta']);
I added:
app.run(['ngMeta', '$rootScope' , '$location', '$window', function(ngMeta,$rootScope , $location, $window) {
ngMeta.init();
$window.gtag('create', 'GOOGLE-ID', 'auto');
$rootScope.$on('$stateChangeSuccess', function (event) {
$window.gtag('send', 'pageview', $location.path());
});
}]);
But I'm not able to see any hits on the analytics page, except for the index.