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() {
// Record routing for analytics
this.router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe((event: NavigationEnd) => {
(<any>window).ga('set', 'page', event.urlAfterRedirects);
(<any>window).ga('send', 'pageview');
let ga = (<any>window).ga;
if (ga) {
ga('set', 'page', event.urlAfterRedirects);
ga('send', 'pageview');
}
});
// 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>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-78788876-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'UA-78788876-2');
(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', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-78788876-2', 'auto');
</script>
</head>