Call matomo manually on Turbo page visits

This commit is contained in:
Matt-Yorkley
2023-05-23 23:43:22 +01:00
committed by Filipe
parent a0a1f8f910
commit ace2c5778f
3 changed files with 12 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
// Call Matomo on asynchronous page loads
["turbo:load", "ujs:afterMorph"].forEach((listener) =>
document.addEventListener(listener, (event) => {
if (typeof event?.detail?.timing === "object" && Object.keys(event?.detail?.timing).length === 0) {
return;
}
window._mtm?.push({ "event": "mtm.PageView" });
})
);

View File

@@ -2,6 +2,7 @@ import "controllers";
import "channels";
import "@hotwired/turbo";
import "../js/mrujs";
import "../js/matomo";
import "../js/moment";
import bigDecimal from "js-big-decimal";

View File

@@ -1,6 +1,7 @@
import "controllers";
import "@hotwired/turbo";
import "../js/mrujs";
import "../js/matomo";
import "../js/moment";
require.context("../fonts", true);