Hola, para integrar Matomo en DSpace 7.x, me sirvio modificar el archivo footer.component.ts, dentro del archivo debes colocar lo siguiente:
import { Component, AfterViewInit, Renderer2, ElementRef } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { FooterComponent as BaseComponent } from '../../../../app/footer/footer.component';
declare global {
interface Window {
_paq: any[];
}
}
@Component({
selector: 'ds-footer',
styleUrls: ['footer.component.scss'],
templateUrl: 'footer.component.html'
})
export class FooterComponent implements AfterViewInit {
currentYear = new Date().getFullYear();
private previousPageUrl: string;
constructor(
private renderer: Renderer2,
private el: ElementRef,
private router: Router
) {}
ngAfterViewInit() {
this.initializeMatomo();
this.trackPageViews();
}
private initializeMatomo() {
window._paq = window._paq || [];
window._paq.push(['trackPageView']);
window._paq.push(['enableLinkTracking']);
window._paq.push(['setTrackerUrl', '//URL_MATOMO/matomo.php']);
window._paq.push(['setSiteId', '1']);
const script = this.renderer.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.src = '//
URL_MATOMO/matomo.js';
this.renderer.appendChild(this.el.nativeElement, script);
}
private trackPageViews() {
this.router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
if (this.previousPageUrl) {
window._paq.push(['setReferrerUrl', this.previousPageUrl]);
}
window._paq.push(['setCustomUrl', window.location.pathname + window.location.search]);
window._paq.push(['setDocumentTitle', document.title]);
window._paq.push(['trackPageView']);
this.previousPageUrl = window.location.href;
}
});
}
}
De esta forma Matomo comenzará a rastrear toda la actividad dentro de DSpace. Luego solo debes incorporar el atributo download="download" dentro del archivo file-download-link.html
<a [routerLink]="(bitstreamPath$| async)?.routerLink" download="download" class="dont-break-out" [queryParams]="(bitstreamPath$| async)?.queryParams" [target]="isBlank ? '_blank': '_self'" [ngClass]="cssClasses">
Agregando el atributo download, matomo comprende que cuando el usuario hace clic en el enlace de descarga, es efectivamente una descarga.
Aplicando estos cambios, Matomo debería capturar datos sin problema, al menos a mi me funciona sin problema.