1 ...
2import{Router, NavigationEnd} from '@angular/router';
3...
4declare let gtag: Function;
5...
6export class AppComponent {
7 constructor(public router: Router){
8 this.router.events.subscribe(event => {
9 if(event instanceof NavigationEnd){
10 gtag('config', 'xx-xxxxx-xx',
11 {
12 'page_path': event.urlAfterRedirects
13 }
14 );
15 }
16 }
17 )}
18}