add google analytics

This commit is contained in:
2021-12-17 22:27:55 -06:00
parent 395780a722
commit 8c49fc7f3d
6 changed files with 74 additions and 3 deletions
+12 -1
View File
@@ -1,4 +1,7 @@
import { Component } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
declare let gtag: Function;
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
@@ -6,5 +9,13 @@ import { Component } from '@angular/core';
})
export class AppComponent {
constructor() { }
constructor(public router: Router) {
this.router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
gtag('config', 'G-48B6CKS0V6',{
'page_path': event.urlAfterRedirects
});
}
})
}
}