From 881671fbfe1e81a42725f898d6642db48e76be55 Mon Sep 17 00:00:00 2001 From: Carlos Mogas da Silva Date: Fri, 14 May 2021 01:20:07 +0100 Subject: [PATCH] Fix cookie usage detection --- static/assets/hugo-matomo.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/static/assets/hugo-matomo.js b/static/assets/hugo-matomo.js index d525100..f6a7ac5 100644 --- a/static/assets/hugo-matomo.js +++ b/static/assets/hugo-matomo.js @@ -14,12 +14,11 @@ function dismissPopup() { } function updateCookieConsent() { - t=Matomo.getTracker(matomoHostURL, matomoSiteId); - when = t.getRememberedCookieConsent(); + t=Matomo.getAsyncTracker(); button = document.getElementById("cookiesaction"); text = button.parentNode.getElementsByTagName('span')[0] - if (when == 0) { + if (!t.areCookiesEnabled()) { text.innerHTML = "You haven't allowed cookies to be used" button.innerHTML = "Allow" button.style.visibility = "" @@ -33,13 +32,13 @@ function updateCookieConsent() { } function stopCookieConsent() { - t=Matomo.getTracker(matomoHostURL, matomoSiteId); + t=Matomo.getAsyncTracker(); t.forgetCookieConsentGiven(); updateCookieConsent(); } function startCookieConsent() { - t=Matomo.getTracker(matomoHostURL, matomoSiteId); + t=Matomo.getAsyncTracker(); t.rememberCookieConsentGiven(); updateCookieConsent(); }