angulartics / angulartics2

Vendor-agnostic analytics for Angular2 applications.
MIT License
1.01k stars 192 forks source link

Pageview not tracked on parameter change #349

Open alex88 opened 5 years ago

alex88 commented 5 years ago

I'm submitting a ...

I've enabled angulartics with google analytics like this:

module.ts

    Angulartics2Module.forRoot({
      pageTracking: {
        clearIds: true,
      }
    }),

app.component.ts

  constructor(private angulartics2GoogleAnalytics: Angulartics2GoogleAnalytics) {
    this.angulartics2GoogleAnalytics.startTracking();
  }

routes.ts
const routes: Routes = [
  { path: 'login', component: LoginComponent },
  { path: 'posts/:id', children: [
    { path: '', pathMatch: 'full', redirectTo: 'home' },
    { path: ':tab', component: PostComponent }
  ]},
  { path: '**', redirectTo: '/login' }
];

On the first page load I correctly get the pageview tracked, when in my code I run:

this.router.navigate([`../${tab}`], { relativeTo: this.route });

to change the tab parameter nothing is tracked

A pageview with the updated tab parameter should be tracked

Angular CLI: 8.0.2
Node: 12.4.0
OS: darwin x64
Angular: 8.0.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.2
@angular-devkit/build-angular     0.800.2
@angular-devkit/build-optimizer   0.800.2
@angular-devkit/build-webpack     0.800.2
@angular-devkit/core              8.0.2
@angular-devkit/schematics        8.0.2
@angular/cli                      8.0.2
@angular/http                     7.2.15
@angular/pwa                      0.800.2
@ngtools/webpack                  8.0.2
@schematics/angular               8.0.2
@schematics/update                0.800.2
rxjs                              6.5.2
typescript                        3.4.5
webpack                           4.30.0
alex88 commented 5 years ago

Sorry by fault, the fact that I was double-navigating the same url won't trigger the NavigationEnd but instead a NavigationCancel on the second navigation and that was blocking angulartics to track the page view