diff --git a/src/app/shared/search/search.component.ts b/src/app/shared/search/search.component.ts index 492c0e3d6b1..d2343234cc5 100644 --- a/src/app/shared/search/search.component.ts +++ b/src/app/shared/search/search.component.ts @@ -485,18 +485,20 @@ export class SearchComponent implements OnDestroy, OnInit { * This method should only be called once and is essentially what SearchTrackingComponent used to do (now removed) * @private */ - private subscribeToRoutingEvents() { - this.subs.push( - this.router.events.pipe( - filter((event) => event instanceof NavigationStart), - map((event: NavigationStart) => this.getDsoUUIDFromUrl(event.url)), - hasValueOperator(), - ).subscribe((uuid) => { - if (this.resultsRD$.value.hasSucceeded) { - this.service.trackSearch(this.searchOptions$.value, this.resultsRD$.value.payload as SearchObjects, uuid); - } - }), - ); + private subscribeToRoutingEvents(): void { + if (this.trackStatistics) { + this.subs.push( + this.router.events.pipe( + filter((event) => event instanceof NavigationStart), + map((event: NavigationStart) => this.getDsoUUIDFromUrl(event.url)), + hasValueOperator(), + ).subscribe((uuid) => { + if (this.resultsRD$.value.hasSucceeded) { + this.service.trackSearch(this.searchOptions$.value, this.resultsRD$.value.payload as SearchObjects, uuid); + } + }), + ); + } } /**