-
Notifications
You must be signed in to change notification settings - Fork 45
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
trackPageView #28
Comments
That is curious, your code seems to be OK. You could maybe call setUserId only when a new user logs in, but that is not going to change the behavior you observe. Do you have a stack trace showing where's it's blocked? Is your Matomo version quite up to date? |
We just had a similar issue with browser freeze, caused by a matomo call never ending. You should check your html structure to check if there is something like us. I don't know if the issue is matomo or ngx-matomo (my bet on matomo). |
Thanks @mgohin for this related issue. I'm curious to know if your problem is being solved by switching the renderer to Ivy. It would not be an ideal solution, but would rather indicate that the problem is partially linked to the code generated by the renderer. Also, keep in mind that Ivy shall be the new default renderer in Angular 9. |
I'll answer in matomo's issue while we are investigating, I'm not sure your plugin is responsible |
I agree this is very unlikely related to my plugin, since it does not interfere in this example: the Matomo tracker works on its own in this scenario, so it's a problem between the Matomo tracker and the compiled Angular template. However, since two of you experienced the same problem, I'm have a look at it, at least to be able to give hints or solutions to future similar problems. |
I face similar issues with looping matomo requests. And for me the same question: I setup matomo in my app.component.ts
Do I need to call this in every component I have? I work with child components and in my onInit I have always:
|
Hi @kombasltd, First, you must only use the injector once : it adds the Matomo tracker directly into the DOM. I have tested multiple injections, but it may have side-effects. Then, you only call If you want to have all components of a page be tracked, you can use trackPageView for each one of them, but I have not tested this use case. So, if you call |
The problem seems to occur if you NOT change the route but the content via a route parameter. Let's say there is a component to show pages within my website. https://mywebsite/home/page1 And the route is
Edit: This is my onInit:
So the onInit tracking in the "ShowPageComponent" is only working for "page1", because onInit is only called once as long as the component is not destroyed. If I change the parameter to "page2" with angular routerlink, onInit is not called anymore - the new content is fetched via the resolver and the subscription. So I need to put the trackPageView somewhere else. And for now I put it in ngDoCheck. Maybe that's causing the issue. Ah damn: I stumbled about my own explaination here to find the solution ;-)
I need to put everything into the subscription function. So it's called everytime if something changes and it's called only once for each change. |
Hi, i tried different things but the same issue occurs again, only on firefox. On chrome version 80.0.3987.149, it works. On firefox, after a manual stop of the javascript process which hangs the browser (does not occur if i remove the trackPageView call), here is the stacktrace: |
I found myself into the same issue here, 100% cpu load and browser freeze. The moment I comment that Is there any update about this case? |
Hi,
something is not clear for me. Is it necessary to call matomoTracker.trackPageView() to track a page view ? It seems it is to see it in the matomo dashboard.
Example of code (Angular 8), with a singleton service injected in components, and a call of trackPageViewToMatomo from the ngOnInit() of these components:
`
constructor(private matomoTracker: MatomoTracker, private userService: UserService) { }
trackPageViewToMatomo(router: Router, route: ActivatedRoute) {
const pageUrl = router.url;
const pageComponent = route.component['name'];
// this.matomoTracker.enableHeartBeatTimer(10);
// this.matomoTracker.enableLinkTracking(true);
this.matomoTracker.setUserId(this.userService.getUserLogin());
this.matomoTracker.setCustomUrl(pageUrl);
this.matomoTracker.setDocumentTitle(pageComponent);
// this.matomoTracker.setGenerationTimeMs(0); // if compute of page generation time
this.matomoTracker.trackPageView();
}
`
The issue i have is the call of trackPageView leads to browser freezes (chrome and firefox), even if i do this call in a delayed observable.
The text was updated successfully, but these errors were encountered: