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

Support for other Analytics service is required to be GDPR compliant #8414

Open
abollini opened this issue Jul 19, 2022 · 5 comments · May be fixed by DSpace/dspace-angular#4018
Open

Support for other Analytics service is required to be GDPR compliant #8414

abollini opened this issue Jul 19, 2022 · 5 comments · May be fixed by DSpace/dspace-angular#4018
Labels
component: statistics Related to Statistics (Solr or Google Analytics) e/40 Estimate in hours help wanted Needs a volunteer to claim to move forward improvement medium priority

Comments

@abollini
Copy link
Member

Due to the controversial use of GA also in version 4 many institution in Europe are looking for different alternative including self hosted analytics service. The most common used alternative both in case of self-hosting than in case of managed European services is Matomo an open source platform. We should add support for it in a similar way to what is currently provided for google analytics.

We (4Science) are interested on working on that, it should take around 3-4 days on the REST part and 2 days on the Angular side

@abollini abollini added new feature needs triage New issue needs triage and/or scheduling labels Jul 19, 2022
@tdonohue
Copy link
Member

Agreed this is a necessary change. However, I'm flagging this as medium priority because another option is to ask people to simply use the internal DSpace Statistics until Matomo support can be added. That said, I'm not against Matomo support overall, it just doesn't seem as high of priority as other 7.4 bug fixes at this time.

@tdonohue tdonohue added component: statistics Related to Statistics (Solr or Google Analytics) medium priority e/40 Estimate in hours and removed needs triage New issue needs triage and/or scheduling labels Jul 19, 2022
@tdonohue tdonohue moved this to To Do in DSpace 7.5 release Oct 11, 2022
@tdonohue tdonohue moved this to 🏗 In Progress in DSpace 7.6 Release Feb 21, 2023
@tdonohue tdonohue moved this from 🏗 In Progress to 📋 To Do in DSpace 7.6 Release Feb 21, 2023
@tdonohue tdonohue added the help wanted Needs a volunteer to claim to move forward label May 15, 2023
@pnbecker
Copy link
Member

I also see a lot of requests in this direction. It would be great to support Matomo!

@mwoodiupui
Copy link
Member

We also are exploring Matomo.

@abollini
Copy link
Member Author

I have created an issue on the OpenAIRE Piwik DSpace project to see if the openaire team is willing to help us with a general solution as their patch is indeed related Piwik = old name of Matomo, OpenAIRE statistics is a central managed instance of Matomo

@sfredesmena
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: statistics Related to Statistics (Solr or Google Analytics) e/40 Estimate in hours help wanted Needs a volunteer to claim to move forward improvement medium priority
Projects
Status: 📋 To Do
Development

Successfully merging a pull request may close this issue.

5 participants