Skip to content

Commit

Permalink
feat: move load.js path to matomo
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandru Medesan authored and Alexandru Medesan committed May 22, 2023
1 parent e986d7a commit c609428
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const loadEuropaAnalyticsScript = () => {
//replace script loaded on each version change
if (existingScript) {
existingScript.setAttribute('src', `https://europa.eu/webtools/load.js`);
existingScript.setAttribute('src', `https://matomo.eea.europa.eu/misc/user/load.js`);
}

if (!existingScript && __CLIENT__) {
Expand All @@ -31,11 +32,21 @@ const loadEuropaAnalyticsScript = () => {
document.body.appendChild(script1);

const script2 = document.createElement('script');
script2.src = `https://europa.eu/webtools/load.js`;
script2.src = `https://matomo.eea.europa.eu/misc/user/load.js`;
script2.id = `europaAnalyticsJS`;
script2.defer = `defer`;
document.body.appendChild(script2);
}
};

export { loadEuropaAnalyticsScript };
const removeEuropaAnalyticsScript = () => {
const existingScript =
__CLIENT__ && document.getElementById(`europaAnalyticsJS`);

//replace script loaded on each route change
if (existingScript) {
existingScript.remove();
}
};

export { loadEuropaAnalyticsScript, removeEuropaAnalyticsScript };

0 comments on commit c609428

Please sign in to comment.