mirror of
https://github.com/Findus23/MatomoLiteTracker.git
synced 2024-09-11 06:43:45 +02:00
track pageview on pageload
This commit is contained in:
parent
a079ab886f
commit
eda41aac10
2 changed files with 9 additions and 1 deletions
|
@ -14,4 +14,4 @@ matomo.customDimensions = {
|
|||
}
|
||||
|
||||
enableLinkTracking(matomo, defaultDownloadFileExtensions)
|
||||
matomo.trackPageview()
|
||||
matomo.trackPageviewOnPageload()
|
||||
|
|
|
@ -255,4 +255,12 @@ export class MatomoLiteTracker {
|
|||
fetch(url, options).then()
|
||||
}
|
||||
}
|
||||
|
||||
trackPageviewOnPageload(customTitle?: string) {
|
||||
if (document.readyState == "complete") {
|
||||
this.trackPageview(customTitle)
|
||||
} else {
|
||||
document.addEventListener("DOMContentLoaded", () => this.trackPageview(customTitle))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue