🐛 Correction du tracking Matomo

Les urls remontées n'étaient pas mises à jour lors de la navigation
pull/1182/head
Maxime Quandalle 2020-10-31 20:37:45 +01:00
parent 1b57f679a1
commit 947cffbff4
1 changed files with 12 additions and 1 deletions

View File

@ -7,7 +7,12 @@ declare global {
}
}
type PushArgs = ['trackPageView'] | ['trackEvent', ...Array<string | number>]
type MatomoAction =
| 'trackPageView'
| 'trackEvent'
| 'setReferrerUrl'
| 'setCustomUrl'
type PushArgs = [MatomoAction, ...Array<string | number>]
type PushType = (args: PushArgs) => void
const ua = window.navigator.userAgent
@ -60,6 +65,12 @@ export default class Tracker {
if (this.previousPath === currentPath) {
return
}
if (this.previousPath) {
this.push(['setReferrerUrl', this.previousPath])
}
this.push(['setCustomUrl', currentPath])
// TODO: We should also call 'setDocumentTitle' but at this point the
// document.title isn't updated yet.
this.push(['trackPageView'])
this.previousPath = currentPath
}