angular-gtag
angular-gtag copied to clipboard
Change default page_title
In automatic tracking of Pageviews, is there a way to change page_title
default value 'Angular App', to another value or to a real document title?
Hi. I changed trackPageviews to false in app.module.ts : GtagModule.forRoot( { trackingId: '...', trackPageviews: false });
and set the page title on each page change using the following in ngOnInit() in app.component.ts :
this.router.events.subscribe(event => { if (event instanceof NavigationEnd) { this.gtag.pageview({ page_title: this.titleService.getTitle(), page_path: this.router.url, page_location: environment.server + this.router.url }); } });
(titleService is of type Title imported from @angular/platform-browser.)
But I'm not getting the gtagEvents -- i.e., in your example, gtagEvent trackOn="dragstart" action="product_dragged" category="ecommerce" [params]="{ event_label: 'Something cool just happened' }"
Is this because trackPageviews is set to false ?
If trackPageviews is set to true though, the same page will get two entries per visit -- one the default call to pageview() -- with page title "Angular App" and one for the call we make manually.
Any suggestions on how to also get the gtagEvent directive to work?