From 85f41e5c95fd874c36fa1a687cc7626c82a07711 Mon Sep 17 00:00:00 2001 From: Vigdis Date: Fri, 24 Feb 2023 12:01:05 +0100 Subject: [PATCH] Fix bug with matomo only working on site mounted on domain root --- gradle.properties | 2 +- src/main/resources/site/processors/matomo-report.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 0c5a394..ace529c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,4 +8,4 @@ displayName = Matomo Analytics App vendor = Bouvet Norge AS vendorUrl = https://www.bouvet.no xpVersion = 7.5.0 -version = 1.3.0 +version = 1.3.1 diff --git a/src/main/resources/site/processors/matomo-report.js b/src/main/resources/site/processors/matomo-report.js index 3651116..ecd8525 100644 --- a/src/main/resources/site/processors/matomo-report.js +++ b/src/main/resources/site/processors/matomo-report.js @@ -62,7 +62,13 @@ exports.responseProcessor = function (req, res) { hash = hashCode(req.cookies["no-bouvet-app-matomo_disabled"] + ""); // Create a unique hash if user has consented to tracking. } - res.pageContributions.headEnd.push(""); + let siteRootPath = portalLib.pageUrl({ id: portalLib.getSite()._id }); + // Site vhost is mounted on domain root, e.g. www.example.com + if (siteRootPath === "/") { + siteRootPath = ""; + } + + res.pageContributions.headEnd.push(""); if (matomoTagManagerContainerId) { res.pageContributions.headEnd.push(""); }