mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-28 21:07:16 +00:00
Call matomo manually on Turbo page visits
This commit is contained in:
10
app/webpacker/js/matomo.js
Normal file
10
app/webpacker/js/matomo.js
Normal 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" });
|
||||
})
|
||||
);
|
||||
@@ -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";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import "controllers";
|
||||
import "@hotwired/turbo";
|
||||
import "../js/mrujs";
|
||||
import "../js/matomo";
|
||||
import "../js/moment";
|
||||
|
||||
require.context("../fonts", true);
|
||||
|
||||
Reference in New Issue
Block a user