Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default page_title #7

Open
roffus opened this issue Dec 6, 2018 · 1 comment
Open

Change default page_title #7

roffus opened this issue Dec 6, 2018 · 1 comment

Comments

@roffus
Copy link

roffus commented Dec 6, 2018

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?

@amarnathm
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants