Fixed google analytics live tracking

This commit is contained in:
Zakary Timson 2018-07-14 12:23:00 -04:00
parent 177a671c69
commit dae9910174
2 changed files with 12 additions and 8 deletions

View File

@ -18,8 +18,11 @@ export class AppComponent implements OnInit {
ngOnInit() { ngOnInit() {
// Record routing for analytics // Record routing for analytics
this.router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe((event: NavigationEnd) => { this.router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe((event: NavigationEnd) => {
(<any>window).ga('set', 'page', event.urlAfterRedirects); let ga = (<any>window).ga;
(<any>window).ga('send', 'pageview'); if (ga) {
ga('set', 'page', event.urlAfterRedirects);
ga('send', 'pageview');
}
}); });
// Send electron users right to formula manager // Send electron users right to formula manager

View File

@ -23,13 +23,14 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/js/bootstrap.min.js"></script>
<!-- Global site tag (gtag.js) - Google Analytics --> <!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-78788876-2"></script>
<script> <script>
window.dataLayer = window.dataLayer || []; (function (i, s, o, g, r, a, m) {
function gtag() { dataLayer.push(arguments); } i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
gtag('js', new Date()); (i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
gtag('config', 'UA-78788876-2'); m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-78788876-2', 'auto');
</script> </script>
</head> </head>