mirror of
https://github.com/audacity/audacity.github.io.git
synced 2026-06-14 16:22:58 -05:00
fix matomo
This commit is contained in:
@@ -22,9 +22,6 @@ const saveAcceptToStorage = () =>
|
||||
const saveRejectToStorage = () =>
|
||||
storageType.setItem(consentPropertyName, false);
|
||||
const applyMatomoTrackingCode = () => {
|
||||
console.log(
|
||||
"audacity-consent cookie created, running Matomo tracking code..."
|
||||
);
|
||||
var _paq = (window._paq = window._paq || []);
|
||||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
|
||||
_paq.push(["trackPageView"]);
|
||||
@@ -42,6 +39,21 @@ const applyMatomoTrackingCode = () => {
|
||||
})();
|
||||
};
|
||||
|
||||
const applyMatomoTrackingCodeWithoutCookies = () => {
|
||||
var _paq = window._paq = window._paq || [];
|
||||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
|
||||
_paq.push(["disableCookies"]);
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function() {
|
||||
var u="https://matomo.audacityteam.org/";
|
||||
_paq.push(['setTrackerUrl', u+'matomo.php']);
|
||||
_paq.push(['setSiteId', '2']);
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
};
|
||||
|
||||
window.onload = () => {
|
||||
const consentPopup = document.getElementById("consent-popup");
|
||||
const acceptBtn = document.getElementById("accept");
|
||||
@@ -56,6 +68,7 @@ window.onload = () => {
|
||||
const rejectCookie = (event) => {
|
||||
saveRejectToStorage(storageType);
|
||||
consentPopup.classList.add("hide");
|
||||
applyMatomoTrackingCodeWithoutCookies();
|
||||
};
|
||||
|
||||
acceptBtn.addEventListener("click", acceptCookie);
|
||||
|
||||
@@ -5,9 +5,6 @@ const getCookie = (name) => {
|
||||
}
|
||||
|
||||
if (getCookie("audacity_consent") === "true") {
|
||||
console.log(
|
||||
"audacity_consent cookie found, loading Matomo tracking code..."
|
||||
);
|
||||
var _paq = (window._paq = window._paq || []);
|
||||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
|
||||
_paq.push(["trackPageView"]);
|
||||
@@ -23,4 +20,17 @@ const getCookie = (name) => {
|
||||
g.src = u + "matomo.js";
|
||||
s.parentNode.insertBefore(g, s);
|
||||
})();
|
||||
} else {
|
||||
var _paq = window._paq = window._paq || [];
|
||||
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
|
||||
_paq.push(["disableCookies"]);
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function() {
|
||||
var u="https://matomo.audacityteam.org/";
|
||||
_paq.push(['setTrackerUrl', u+'matomo.php']);
|
||||
_paq.push(['setSiteId', '2']);
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
}
|
||||
Reference in New Issue
Block a user