From 6f1d6f4a8e874636cc4713d9838de96b533fb263 Mon Sep 17 00:00:00 2001 From: Jere Ljungberg Date: Fri, 14 Feb 2025 13:35:25 +0200 Subject: [PATCH 1/4] Add reading matomo js api key from drupalSettings --- dist/js/matomo.min.js | 2 +- src/js/matomo.js | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/dist/js/matomo.min.js b/dist/js/matomo.min.js index 5a37c30cd..adf56818d 100644 --- a/dist/js/matomo.min.js +++ b/dist/js/matomo.min.js @@ -1 +1 @@ -!function(){function e(){let e=null;window.innerWidth?e=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?e=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(e=document.body.clientWidth),"number"==typeof e&&(e=10*Math.round(e/10));let t=null;return window.innerHeight?t=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?t=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(t=document.body.clientHeight),"number"==typeof t&&(t=10*Math.round(t/10)),`${e}x${t}`}!function(t,Drupal){function n(){const t="?9mt5bfb2bGk="===window.location.search;if(t){console.info("Using JavaScript Tracking");const t=()=>window.innerWidth,n=()=>window.innerHeight,i=()=>document.querySelector("html")?.attributes?.lang?.value||"unkown",o=()=>document.querySelector('meta[property="article:published_time"]')?.content||"",s=()=>document.querySelector('meta[property="og:updated_time"]')?.content||"",a=window._paq=window._paq||[];a.push(["setExcludedQueryParams",["maintheme","channeltype","errandservicetype","targetgroup","year","doc","ls","vdoc","dkey","pno","dir","buttonName","familyIncome","fulltime","daysoff","familySize","submitButton","cn","pd","sivu","tyoPaikkaAla","HELP_MODE","tyoSanaHakuKentta","SHOW_TOOLS","haeTyopaikkojaBTN","nayta-kesa","redir","chatMode","id","Id","feedbackId","fid","up","p","c","tyoSuhtTyyppi","kielisyys","cityarea","selection","contentViewMode","v","INFO_MODE","EDIT_MODE","PAGE_MODES","showyears","categories","categories2","MOD","newfeatures","format","contentID","useDefaultText","useDefaultDesc","li_fat_id","lmod","CACHEID","__FB_PRIVATE_TRACKING__","as_qdr","as_occt","as_q","contentIDR","id-2939","redir3","urile","sa","ved","resetButton","hcb","cep","service_node","setlanguage","continueFlag","nayta-kaikki","trk","existed","logout","attachedData","next","ref_ttesl_hdh_ep1","sort","customerid","CVID","amp","1dmy","osoite","mailto","Siirtyy%20jaoston%20päätösasiakirjoihin.","Siirtyy%20sivutossa%20jaoston%20päätösasiakirjojen%20kohtaan.","v:file","v:state","btnG","current","readclass","safe","/'javascript:?%27%20class=%27ch2-open-settings-btn%27%20onClick=%27cookiehub.openSettings()%27","row","start","end","mode","zarsrc","gws_rd","showfromdate","^.*\\@hel.fi$","' class","%27%20class","class","_sm_au_","action","Siirtyy jaoston päätösasiakirjoihin.","Siirtyy sivutossa jaoston päätösasiakirjojen kohtaan.","ISCI","usein kysyttyä palveluverkkosuunnittelusta","Pelastussuunnitelma","Palotarkastus","recepient","Action","amp;current","XIe","dNe","mc_cid","mc_eid","added","client-request-id","estsrequest","ceid","emid","crmid","identify","elq","elqaid","elqat","classId","assignmentId","gidzl","_hsmi","_hsenc","tre","trete","pe_data","o4e","n4e","check_logged_in","code","u4e","itok","WCM_PORTLET","SessionExpired","KYe","WCM_GLOBAL_CONTEXT","frosmo","C_e","name","state","ttclid","acaToken","wvstest","max-depth","__proto__[crVsaSZqMnW4EqBoI22emA]","__proto__.crVsaSZqMnW4EqBoI22emA","constructor.prototype[crVsaSZqMnW4EqBoI22emA]","constructor.prototype.crVsaSZqMnW4EqBoI22emA","constructor[prototype][crVsaSZqMnW4EqBoI22emA]","gsid","fbclid","time","complianz_scan_token","complianz_id"]]),a.push(["setCustomDimension",2,t()]),a.push(["setCustomDimension",3,n()]),a.push(["setCustomDimension",4,i()]),a.push(["setCustomDimension",5,o()]),a.push(["setCustomDimension",6,s()]),a.push(["setCustomDimension",7,e()]),a.push(["trackPageView"]),a.push(["enableLinkTracking"]),function(){const e="//webanalytics.digiaiiris.com/js/";a.push(["setTrackerUrl",`${e}tracker.php`]),a.push(["setSiteId","141"]);const t=document,n=t.createElement("script"),i=t.getElementsByTagName("script")[0];n.async=!0,n.src=`${e}piwik.min.js`,i.parentNode.insertBefore(n,i)}()}if(!t&&Drupal.cookieConsent.getConsentStatus(["statistics"])){(window._mtm=window._mtm||[]).push({"mtm.startTime":(new Date).getTime(),event:"mtm.Start"});const e=document,t=e.createElement("script"),n=e.getElementsByTagName("script")[0];t.type="text/javascript",t.async=!0,t.src="//webanalytics.digiaiiris.com/js/container_X3dUNyXY.js",n.parentNode.insertBefore(t,n)}}Drupal.cookieConsent.initialized()?n():Drupal.cookieConsent.loadFunction(n)}(jQuery,Drupal)}(); \ No newline at end of file +!function(){function e(){let e=null;window.innerWidth?e=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?e=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(e=document.body.clientWidth),"number"==typeof e&&(e=10*Math.round(e/10));let t=null;return window.innerHeight?t=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?t=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(t=document.body.clientHeight),"number"==typeof t&&(t=10*Math.round(t/10)),`${e}x${t}`}!function(t,Drupal){function n(){const t=drupalSettings.matomo_js_api_key;if(t&&Drupal.cookieConsent.getConsentStatus(["statistics"])){const n=()=>window.innerWidth,i=()=>window.innerHeight,o=()=>document.querySelector("html")?.attributes?.lang?.value||"unkown",s=()=>document.querySelector('meta[property="article:published_time"]')?.content||"",a=()=>document.querySelector('meta[property="og:updated_time"]')?.content||"",c=window._paq=window._paq||[];c.push(["setExcludedQueryParams",["maintheme","channeltype","errandservicetype","targetgroup","year","doc","ls","vdoc","dkey","pno","dir","buttonName","familyIncome","fulltime","daysoff","familySize","submitButton","cn","pd","sivu","tyoPaikkaAla","HELP_MODE","tyoSanaHakuKentta","SHOW_TOOLS","haeTyopaikkojaBTN","nayta-kesa","redir","chatMode","id","Id","feedbackId","fid","up","p","c","tyoSuhtTyyppi","kielisyys","cityarea","selection","contentViewMode","v","INFO_MODE","EDIT_MODE","PAGE_MODES","showyears","categories","categories2","MOD","newfeatures","format","contentID","useDefaultText","useDefaultDesc","li_fat_id","lmod","CACHEID","__FB_PRIVATE_TRACKING__","as_qdr","as_occt","as_q","contentIDR","id-2939","redir3","urile","sa","ved","resetButton","hcb","cep","service_node","setlanguage","continueFlag","nayta-kaikki","trk","existed","logout","attachedData","next","ref_ttesl_hdh_ep1","sort","customerid","CVID","amp","1dmy","osoite","mailto","Siirtyy%20jaoston%20päätösasiakirjoihin.","Siirtyy%20sivutossa%20jaoston%20päätösasiakirjojen%20kohtaan.","v:file","v:state","btnG","current","readclass","safe","/'javascript:?%27%20class=%27ch2-open-settings-btn%27%20onClick=%27cookiehub.openSettings()%27","row","start","end","mode","zarsrc","gws_rd","showfromdate","^.*\\@hel.fi$","' class","%27%20class","class","_sm_au_","action","Siirtyy jaoston päätösasiakirjoihin.","Siirtyy sivutossa jaoston päätösasiakirjojen kohtaan.","ISCI","usein kysyttyä palveluverkkosuunnittelusta","Pelastussuunnitelma","Palotarkastus","recepient","Action","amp;current","XIe","dNe","mc_cid","mc_eid","added","client-request-id","estsrequest","ceid","emid","crmid","identify","elq","elqaid","elqat","classId","assignmentId","gidzl","_hsmi","_hsenc","tre","trete","pe_data","o4e","n4e","check_logged_in","code","u4e","itok","WCM_PORTLET","SessionExpired","KYe","WCM_GLOBAL_CONTEXT","frosmo","C_e","name","state","ttclid","acaToken","wvstest","max-depth","__proto__[crVsaSZqMnW4EqBoI22emA]","__proto__.crVsaSZqMnW4EqBoI22emA","constructor.prototype[crVsaSZqMnW4EqBoI22emA]","constructor.prototype.crVsaSZqMnW4EqBoI22emA","constructor[prototype][crVsaSZqMnW4EqBoI22emA]","gsid","fbclid","time","complianz_scan_token","complianz_id"]]),c.push(["setCustomDimension",2,n()]),c.push(["setCustomDimension",3,i()]),c.push(["setCustomDimension",4,o()]),c.push(["setCustomDimension",5,s()]),c.push(["setCustomDimension",6,a()]),c.push(["setCustomDimension",7,e()]),c.push(["trackPageView"]),c.push(["enableLinkTracking"]),function(){const e="//webanalytics.digiaiiris.com/js/";c.push(["setTrackerUrl",`${e}tracker.php`]),c.push(["setSiteId","141"]),c.push(["addTracker",`${e}tracker.php`],t);const n=document,i=n.createElement("script"),o=n.getElementsByTagName("script")[0];i.async=!0,i.src=`${e}piwik.min.js`,o.parentNode.insertBefore(i,o)}()}if(!useJSAPI&&Drupal.cookieConsent.getConsentStatus(["statistics"])){(window._mtm=window._mtm||[]).push({"mtm.startTime":(new Date).getTime(),event:"mtm.Start"});const e=document,t=e.createElement("script"),n=e.getElementsByTagName("script")[0];t.type="text/javascript",t.async=!0,t.src="//webanalytics.digiaiiris.com/js/container_X3dUNyXY.js",n.parentNode.insertBefore(t,n)}}Drupal.cookieConsent.initialized()?n():Drupal.cookieConsent.loadFunction(n)}(jQuery,Drupal)}(); \ No newline at end of file diff --git a/src/js/matomo.js b/src/js/matomo.js index bd0ed8118..d7e219df5 100644 --- a/src/js/matomo.js +++ b/src/js/matomo.js @@ -1,14 +1,11 @@ // eslint-disable-next-line func-names (function ($, Drupal) { function loadMatomoAnalytics() { - /** - * If the queryparameter is found, the script will be loaded - * regardless of cookie consents etc. - */ - const useJSAPI = window.location.search === '?9mt5bfb2bGk='; - if (useJSAPI) { + + // If matomo_js_api_key value is set, use JS client for matomo analytics + const jsApiKey = drupalSettings.matomo_js_api_key; + if (jsApiKey && Drupal.cookieConsent.getConsentStatus(['statistics'])) { // eslint-disable-next-line no-console - console.info('Using JavaScript Tracking'); const getViewportWidth = () => window.innerWidth; const getViewportHeight = () => window.innerHeight; const getLanguage = () => document.querySelector('html')?.attributes?.lang?.value || 'unkown'; @@ -34,14 +31,14 @@ const u='//webanalytics.digiaiiris.com/js/'; _paq.push(['setTrackerUrl', `${u}tracker.php`]); _paq.push(['setSiteId', '141']); + _paq.push(['addTracker', `${u}tracker.php`], jsApiKey); const d=document; const g=d.createElement('script'); const s=d.getElementsByTagName('script')[0]; // Consider integrity hash check g.async=true; g.src=`${u}piwik.min.js`; s.parentNode.insertBefore(g,s); })(); } - - // Load Matomo only if statistics cookies are allowed. - if (!useJSAPI && Drupal.cookieConsent.getConsentStatus(['statistics'])) { + // Use Matomo tag manager if statistics cookies are allowed. + else if (Drupal.cookieConsent.getConsentStatus(['statistics'])) { // Matomo Tag Manager // eslint-disable-next-line no-multi-assign const _mtm = (window._mtm = window._mtm || []); From 7a0a08b05e19f0e4b83abefe9d96445ad59f7cf8 Mon Sep 17 00:00:00 2001 From: Jere Ljungberg Date: Fri, 14 Feb 2025 14:10:59 +0200 Subject: [PATCH 2/4] Change variable name --- dist/js/matomo.min.js | 2 +- src/js/matomo.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dist/js/matomo.min.js b/dist/js/matomo.min.js index adf56818d..507e2140f 100644 --- a/dist/js/matomo.min.js +++ b/dist/js/matomo.min.js @@ -1 +1 @@ -!function(){function e(){let e=null;window.innerWidth?e=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?e=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(e=document.body.clientWidth),"number"==typeof e&&(e=10*Math.round(e/10));let t=null;return window.innerHeight?t=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?t=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(t=document.body.clientHeight),"number"==typeof t&&(t=10*Math.round(t/10)),`${e}x${t}`}!function(t,Drupal){function n(){const t=drupalSettings.matomo_js_api_key;if(t&&Drupal.cookieConsent.getConsentStatus(["statistics"])){const n=()=>window.innerWidth,i=()=>window.innerHeight,o=()=>document.querySelector("html")?.attributes?.lang?.value||"unkown",s=()=>document.querySelector('meta[property="article:published_time"]')?.content||"",a=()=>document.querySelector('meta[property="og:updated_time"]')?.content||"",c=window._paq=window._paq||[];c.push(["setExcludedQueryParams",["maintheme","channeltype","errandservicetype","targetgroup","year","doc","ls","vdoc","dkey","pno","dir","buttonName","familyIncome","fulltime","daysoff","familySize","submitButton","cn","pd","sivu","tyoPaikkaAla","HELP_MODE","tyoSanaHakuKentta","SHOW_TOOLS","haeTyopaikkojaBTN","nayta-kesa","redir","chatMode","id","Id","feedbackId","fid","up","p","c","tyoSuhtTyyppi","kielisyys","cityarea","selection","contentViewMode","v","INFO_MODE","EDIT_MODE","PAGE_MODES","showyears","categories","categories2","MOD","newfeatures","format","contentID","useDefaultText","useDefaultDesc","li_fat_id","lmod","CACHEID","__FB_PRIVATE_TRACKING__","as_qdr","as_occt","as_q","contentIDR","id-2939","redir3","urile","sa","ved","resetButton","hcb","cep","service_node","setlanguage","continueFlag","nayta-kaikki","trk","existed","logout","attachedData","next","ref_ttesl_hdh_ep1","sort","customerid","CVID","amp","1dmy","osoite","mailto","Siirtyy%20jaoston%20päätösasiakirjoihin.","Siirtyy%20sivutossa%20jaoston%20päätösasiakirjojen%20kohtaan.","v:file","v:state","btnG","current","readclass","safe","/'javascript:?%27%20class=%27ch2-open-settings-btn%27%20onClick=%27cookiehub.openSettings()%27","row","start","end","mode","zarsrc","gws_rd","showfromdate","^.*\\@hel.fi$","' class","%27%20class","class","_sm_au_","action","Siirtyy jaoston päätösasiakirjoihin.","Siirtyy sivutossa jaoston päätösasiakirjojen kohtaan.","ISCI","usein kysyttyä palveluverkkosuunnittelusta","Pelastussuunnitelma","Palotarkastus","recepient","Action","amp;current","XIe","dNe","mc_cid","mc_eid","added","client-request-id","estsrequest","ceid","emid","crmid","identify","elq","elqaid","elqat","classId","assignmentId","gidzl","_hsmi","_hsenc","tre","trete","pe_data","o4e","n4e","check_logged_in","code","u4e","itok","WCM_PORTLET","SessionExpired","KYe","WCM_GLOBAL_CONTEXT","frosmo","C_e","name","state","ttclid","acaToken","wvstest","max-depth","__proto__[crVsaSZqMnW4EqBoI22emA]","__proto__.crVsaSZqMnW4EqBoI22emA","constructor.prototype[crVsaSZqMnW4EqBoI22emA]","constructor.prototype.crVsaSZqMnW4EqBoI22emA","constructor[prototype][crVsaSZqMnW4EqBoI22emA]","gsid","fbclid","time","complianz_scan_token","complianz_id"]]),c.push(["setCustomDimension",2,n()]),c.push(["setCustomDimension",3,i()]),c.push(["setCustomDimension",4,o()]),c.push(["setCustomDimension",5,s()]),c.push(["setCustomDimension",6,a()]),c.push(["setCustomDimension",7,e()]),c.push(["trackPageView"]),c.push(["enableLinkTracking"]),function(){const e="//webanalytics.digiaiiris.com/js/";c.push(["setTrackerUrl",`${e}tracker.php`]),c.push(["setSiteId","141"]),c.push(["addTracker",`${e}tracker.php`],t);const n=document,i=n.createElement("script"),o=n.getElementsByTagName("script")[0];i.async=!0,i.src=`${e}piwik.min.js`,o.parentNode.insertBefore(i,o)}()}if(!useJSAPI&&Drupal.cookieConsent.getConsentStatus(["statistics"])){(window._mtm=window._mtm||[]).push({"mtm.startTime":(new Date).getTime(),event:"mtm.Start"});const e=document,t=e.createElement("script"),n=e.getElementsByTagName("script")[0];t.type="text/javascript",t.async=!0,t.src="//webanalytics.digiaiiris.com/js/container_X3dUNyXY.js",n.parentNode.insertBefore(t,n)}}Drupal.cookieConsent.initialized()?n():Drupal.cookieConsent.loadFunction(n)}(jQuery,Drupal)}(); \ No newline at end of file +!function(){function e(){let e=null;window.innerWidth?e=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?e=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(e=document.body.clientWidth),"number"==typeof e&&(e=10*Math.round(e/10));let t=null;return window.innerHeight?t=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?t=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(t=document.body.clientHeight),"number"==typeof t&&(t=10*Math.round(t/10)),`${e}x${t}`}!function(t,Drupal){function n(){const t=drupalSettings.matomo_js_site_id;if(t&&Drupal.cookieConsent.getConsentStatus(["statistics"])){const n=()=>window.innerWidth,i=()=>window.innerHeight,o=()=>document.querySelector("html")?.attributes?.lang?.value||"unkown",s=()=>document.querySelector('meta[property="article:published_time"]')?.content||"",a=()=>document.querySelector('meta[property="og:updated_time"]')?.content||"",c=window._paq=window._paq||[];c.push(["setExcludedQueryParams",["maintheme","channeltype","errandservicetype","targetgroup","year","doc","ls","vdoc","dkey","pno","dir","buttonName","familyIncome","fulltime","daysoff","familySize","submitButton","cn","pd","sivu","tyoPaikkaAla","HELP_MODE","tyoSanaHakuKentta","SHOW_TOOLS","haeTyopaikkojaBTN","nayta-kesa","redir","chatMode","id","Id","feedbackId","fid","up","p","c","tyoSuhtTyyppi","kielisyys","cityarea","selection","contentViewMode","v","INFO_MODE","EDIT_MODE","PAGE_MODES","showyears","categories","categories2","MOD","newfeatures","format","contentID","useDefaultText","useDefaultDesc","li_fat_id","lmod","CACHEID","__FB_PRIVATE_TRACKING__","as_qdr","as_occt","as_q","contentIDR","id-2939","redir3","urile","sa","ved","resetButton","hcb","cep","service_node","setlanguage","continueFlag","nayta-kaikki","trk","existed","logout","attachedData","next","ref_ttesl_hdh_ep1","sort","customerid","CVID","amp","1dmy","osoite","mailto","Siirtyy%20jaoston%20päätösasiakirjoihin.","Siirtyy%20sivutossa%20jaoston%20päätösasiakirjojen%20kohtaan.","v:file","v:state","btnG","current","readclass","safe","/'javascript:?%27%20class=%27ch2-open-settings-btn%27%20onClick=%27cookiehub.openSettings()%27","row","start","end","mode","zarsrc","gws_rd","showfromdate","^.*\\@hel.fi$","' class","%27%20class","class","_sm_au_","action","Siirtyy jaoston päätösasiakirjoihin.","Siirtyy sivutossa jaoston päätösasiakirjojen kohtaan.","ISCI","usein kysyttyä palveluverkkosuunnittelusta","Pelastussuunnitelma","Palotarkastus","recepient","Action","amp;current","XIe","dNe","mc_cid","mc_eid","added","client-request-id","estsrequest","ceid","emid","crmid","identify","elq","elqaid","elqat","classId","assignmentId","gidzl","_hsmi","_hsenc","tre","trete","pe_data","o4e","n4e","check_logged_in","code","u4e","itok","WCM_PORTLET","SessionExpired","KYe","WCM_GLOBAL_CONTEXT","frosmo","C_e","name","state","ttclid","acaToken","wvstest","max-depth","__proto__[crVsaSZqMnW4EqBoI22emA]","__proto__.crVsaSZqMnW4EqBoI22emA","constructor.prototype[crVsaSZqMnW4EqBoI22emA]","constructor.prototype.crVsaSZqMnW4EqBoI22emA","constructor[prototype][crVsaSZqMnW4EqBoI22emA]","gsid","fbclid","time","complianz_scan_token","complianz_id"]]),c.push(["setCustomDimension",2,n()]),c.push(["setCustomDimension",3,i()]),c.push(["setCustomDimension",4,o()]),c.push(["setCustomDimension",5,s()]),c.push(["setCustomDimension",6,a()]),c.push(["setCustomDimension",7,e()]),c.push(["trackPageView"]),c.push(["enableLinkTracking"]),function(){const e="//webanalytics.digiaiiris.com/js/";c.push(["setTrackerUrl",`${e}tracker.php`]),c.push(["setSiteId","141"]),c.push(["addTracker",`${e}tracker.php`],t);const n=document,i=n.createElement("script"),o=n.getElementsByTagName("script")[0];i.async=!0,i.src=`${e}piwik.min.js`,o.parentNode.insertBefore(i,o)}()}else if(Drupal.cookieConsent.getConsentStatus(["statistics"])){(window._mtm=window._mtm||[]).push({"mtm.startTime":(new Date).getTime(),event:"mtm.Start"});const e=document,t=e.createElement("script"),n=e.getElementsByTagName("script")[0];t.type="text/javascript",t.async=!0,t.src="//webanalytics.digiaiiris.com/js/container_X3dUNyXY.js",n.parentNode.insertBefore(t,n)}}Drupal.cookieConsent.initialized()?n():Drupal.cookieConsent.loadFunction(n)}(jQuery,Drupal)}(); \ No newline at end of file diff --git a/src/js/matomo.js b/src/js/matomo.js index d7e219df5..c4caafc8c 100644 --- a/src/js/matomo.js +++ b/src/js/matomo.js @@ -2,9 +2,9 @@ (function ($, Drupal) { function loadMatomoAnalytics() { - // If matomo_js_api_key value is set, use JS client for matomo analytics - const jsApiKey = drupalSettings.matomo_js_api_key; - if (jsApiKey && Drupal.cookieConsent.getConsentStatus(['statistics'])) { + // If matomo_js_site_id value is set, use JS client for matomo analytics + const siteId = drupalSettings.matomo_js_site_id; + if (siteId && Drupal.cookieConsent.getConsentStatus(['statistics'])) { // eslint-disable-next-line no-console const getViewportWidth = () => window.innerWidth; const getViewportHeight = () => window.innerHeight; @@ -31,7 +31,7 @@ const u='//webanalytics.digiaiiris.com/js/'; _paq.push(['setTrackerUrl', `${u}tracker.php`]); _paq.push(['setSiteId', '141']); - _paq.push(['addTracker', `${u}tracker.php`], jsApiKey); + _paq.push(['addTracker', `${u}tracker.php`], siteId); const d=document; const g=d.createElement('script'); const s=d.getElementsByTagName('script')[0]; // Consider integrity hash check g.async=true; g.src=`${u}piwik.min.js`; s.parentNode.insertBefore(g,s); From d2ea04d19ae579489f38891b2b4eceea38e01d6a Mon Sep 17 00:00:00 2001 From: Jere Ljungberg Date: Fri, 14 Feb 2025 15:42:50 +0200 Subject: [PATCH 3/4] Change condition for loading matomo to drupalSettings variable --- dist/js/matomo.min.js | 2 +- src/js/matomo.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dist/js/matomo.min.js b/dist/js/matomo.min.js index 507e2140f..a7b37e463 100644 --- a/dist/js/matomo.min.js +++ b/dist/js/matomo.min.js @@ -1 +1 @@ -!function(){function e(){let e=null;window.innerWidth?e=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?e=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(e=document.body.clientWidth),"number"==typeof e&&(e=10*Math.round(e/10));let t=null;return window.innerHeight?t=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?t=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(t=document.body.clientHeight),"number"==typeof t&&(t=10*Math.round(t/10)),`${e}x${t}`}!function(t,Drupal){function n(){const t=drupalSettings.matomo_js_site_id;if(t&&Drupal.cookieConsent.getConsentStatus(["statistics"])){const n=()=>window.innerWidth,i=()=>window.innerHeight,o=()=>document.querySelector("html")?.attributes?.lang?.value||"unkown",s=()=>document.querySelector('meta[property="article:published_time"]')?.content||"",a=()=>document.querySelector('meta[property="og:updated_time"]')?.content||"",c=window._paq=window._paq||[];c.push(["setExcludedQueryParams",["maintheme","channeltype","errandservicetype","targetgroup","year","doc","ls","vdoc","dkey","pno","dir","buttonName","familyIncome","fulltime","daysoff","familySize","submitButton","cn","pd","sivu","tyoPaikkaAla","HELP_MODE","tyoSanaHakuKentta","SHOW_TOOLS","haeTyopaikkojaBTN","nayta-kesa","redir","chatMode","id","Id","feedbackId","fid","up","p","c","tyoSuhtTyyppi","kielisyys","cityarea","selection","contentViewMode","v","INFO_MODE","EDIT_MODE","PAGE_MODES","showyears","categories","categories2","MOD","newfeatures","format","contentID","useDefaultText","useDefaultDesc","li_fat_id","lmod","CACHEID","__FB_PRIVATE_TRACKING__","as_qdr","as_occt","as_q","contentIDR","id-2939","redir3","urile","sa","ved","resetButton","hcb","cep","service_node","setlanguage","continueFlag","nayta-kaikki","trk","existed","logout","attachedData","next","ref_ttesl_hdh_ep1","sort","customerid","CVID","amp","1dmy","osoite","mailto","Siirtyy%20jaoston%20päätösasiakirjoihin.","Siirtyy%20sivutossa%20jaoston%20päätösasiakirjojen%20kohtaan.","v:file","v:state","btnG","current","readclass","safe","/'javascript:?%27%20class=%27ch2-open-settings-btn%27%20onClick=%27cookiehub.openSettings()%27","row","start","end","mode","zarsrc","gws_rd","showfromdate","^.*\\@hel.fi$","' class","%27%20class","class","_sm_au_","action","Siirtyy jaoston päätösasiakirjoihin.","Siirtyy sivutossa jaoston päätösasiakirjojen kohtaan.","ISCI","usein kysyttyä palveluverkkosuunnittelusta","Pelastussuunnitelma","Palotarkastus","recepient","Action","amp;current","XIe","dNe","mc_cid","mc_eid","added","client-request-id","estsrequest","ceid","emid","crmid","identify","elq","elqaid","elqat","classId","assignmentId","gidzl","_hsmi","_hsenc","tre","trete","pe_data","o4e","n4e","check_logged_in","code","u4e","itok","WCM_PORTLET","SessionExpired","KYe","WCM_GLOBAL_CONTEXT","frosmo","C_e","name","state","ttclid","acaToken","wvstest","max-depth","__proto__[crVsaSZqMnW4EqBoI22emA]","__proto__.crVsaSZqMnW4EqBoI22emA","constructor.prototype[crVsaSZqMnW4EqBoI22emA]","constructor.prototype.crVsaSZqMnW4EqBoI22emA","constructor[prototype][crVsaSZqMnW4EqBoI22emA]","gsid","fbclid","time","complianz_scan_token","complianz_id"]]),c.push(["setCustomDimension",2,n()]),c.push(["setCustomDimension",3,i()]),c.push(["setCustomDimension",4,o()]),c.push(["setCustomDimension",5,s()]),c.push(["setCustomDimension",6,a()]),c.push(["setCustomDimension",7,e()]),c.push(["trackPageView"]),c.push(["enableLinkTracking"]),function(){const e="//webanalytics.digiaiiris.com/js/";c.push(["setTrackerUrl",`${e}tracker.php`]),c.push(["setSiteId","141"]),c.push(["addTracker",`${e}tracker.php`],t);const n=document,i=n.createElement("script"),o=n.getElementsByTagName("script")[0];i.async=!0,i.src=`${e}piwik.min.js`,o.parentNode.insertBefore(i,o)}()}else if(Drupal.cookieConsent.getConsentStatus(["statistics"])){(window._mtm=window._mtm||[]).push({"mtm.startTime":(new Date).getTime(),event:"mtm.Start"});const e=document,t=e.createElement("script"),n=e.getElementsByTagName("script")[0];t.type="text/javascript",t.async=!0,t.src="//webanalytics.digiaiiris.com/js/container_X3dUNyXY.js",n.parentNode.insertBefore(t,n)}}Drupal.cookieConsent.initialized()?n():Drupal.cookieConsent.loadFunction(n)}(jQuery,Drupal)}(); \ No newline at end of file +!function(){function e(){let e=null;window.innerWidth?e=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?e=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(e=document.body.clientWidth),"number"==typeof e&&(e=10*Math.round(e/10));let t=null;return window.innerHeight?t=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?t=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(t=document.body.clientHeight),"number"==typeof t&&(t=10*Math.round(t/10)),`${e}x${t}`}!function(t,Drupal){function n(){if("asuminen"===drupalSettings.helfi_instance_name&&Drupal.cookieConsent.getConsentStatus(["statistics"])){const t=()=>window.innerWidth,n=()=>window.innerHeight,i=()=>document.querySelector("html")?.attributes?.lang?.value||"unkown",o=()=>document.querySelector('meta[property="article:published_time"]')?.content||"",s=()=>document.querySelector('meta[property="og:updated_time"]')?.content||"",a=window._paq=window._paq||[];a.push(["setExcludedQueryParams",["maintheme","channeltype","errandservicetype","targetgroup","year","doc","ls","vdoc","dkey","pno","dir","buttonName","familyIncome","fulltime","daysoff","familySize","submitButton","cn","pd","sivu","tyoPaikkaAla","HELP_MODE","tyoSanaHakuKentta","SHOW_TOOLS","haeTyopaikkojaBTN","nayta-kesa","redir","chatMode","id","Id","feedbackId","fid","up","p","c","tyoSuhtTyyppi","kielisyys","cityarea","selection","contentViewMode","v","INFO_MODE","EDIT_MODE","PAGE_MODES","showyears","categories","categories2","MOD","newfeatures","format","contentID","useDefaultText","useDefaultDesc","li_fat_id","lmod","CACHEID","__FB_PRIVATE_TRACKING__","as_qdr","as_occt","as_q","contentIDR","id-2939","redir3","urile","sa","ved","resetButton","hcb","cep","service_node","setlanguage","continueFlag","nayta-kaikki","trk","existed","logout","attachedData","next","ref_ttesl_hdh_ep1","sort","customerid","CVID","amp","1dmy","osoite","mailto","Siirtyy%20jaoston%20päätösasiakirjoihin.","Siirtyy%20sivutossa%20jaoston%20päätösasiakirjojen%20kohtaan.","v:file","v:state","btnG","current","readclass","safe","/'javascript:?%27%20class=%27ch2-open-settings-btn%27%20onClick=%27cookiehub.openSettings()%27","row","start","end","mode","zarsrc","gws_rd","showfromdate","^.*\\@hel.fi$","' class","%27%20class","class","_sm_au_","action","Siirtyy jaoston päätösasiakirjoihin.","Siirtyy sivutossa jaoston päätösasiakirjojen kohtaan.","ISCI","usein kysyttyä palveluverkkosuunnittelusta","Pelastussuunnitelma","Palotarkastus","recepient","Action","amp;current","XIe","dNe","mc_cid","mc_eid","added","client-request-id","estsrequest","ceid","emid","crmid","identify","elq","elqaid","elqat","classId","assignmentId","gidzl","_hsmi","_hsenc","tre","trete","pe_data","o4e","n4e","check_logged_in","code","u4e","itok","WCM_PORTLET","SessionExpired","KYe","WCM_GLOBAL_CONTEXT","frosmo","C_e","name","state","ttclid","acaToken","wvstest","max-depth","__proto__[crVsaSZqMnW4EqBoI22emA]","__proto__.crVsaSZqMnW4EqBoI22emA","constructor.prototype[crVsaSZqMnW4EqBoI22emA]","constructor.prototype.crVsaSZqMnW4EqBoI22emA","constructor[prototype][crVsaSZqMnW4EqBoI22emA]","gsid","fbclid","time","complianz_scan_token","complianz_id"]]),a.push(["setCustomDimension",2,t()]),a.push(["setCustomDimension",3,n()]),a.push(["setCustomDimension",4,i()]),a.push(["setCustomDimension",5,o()]),a.push(["setCustomDimension",6,s()]),a.push(["setCustomDimension",7,e()]),a.push(["trackPageView"]),a.push(["enableLinkTracking"]),function(){const e="//webanalytics.digiaiiris.com/js/";a.push(["setTrackerUrl",`${e}tracker.php`]),a.push(["setSiteId","141"]),a.push(["addTracker",`${e}tracker.php`],"1098");const t=document,n=t.createElement("script"),i=t.getElementsByTagName("script")[0];n.async=!0,n.src=`${e}piwik.min.js`,i.parentNode.insertBefore(n,i)}()}else if(Drupal.cookieConsent.getConsentStatus(["statistics"])){(window._mtm=window._mtm||[]).push({"mtm.startTime":(new Date).getTime(),event:"mtm.Start"});const e=document,t=e.createElement("script"),n=e.getElementsByTagName("script")[0];t.type="text/javascript",t.async=!0,t.src="//webanalytics.digiaiiris.com/js/container_X3dUNyXY.js",n.parentNode.insertBefore(t,n)}}Drupal.cookieConsent.initialized()?n():Drupal.cookieConsent.loadFunction(n)}(jQuery,Drupal)}(); \ No newline at end of file diff --git a/src/js/matomo.js b/src/js/matomo.js index c4caafc8c..b85998a08 100644 --- a/src/js/matomo.js +++ b/src/js/matomo.js @@ -2,10 +2,14 @@ (function ($, Drupal) { function loadMatomoAnalytics() { - // If matomo_js_site_id value is set, use JS client for matomo analytics - const siteId = drupalSettings.matomo_js_site_id; - if (siteId && Drupal.cookieConsent.getConsentStatus(['statistics'])) { - // eslint-disable-next-line no-console + /** + * Temporary hard-coded value for using Matomo js client. + * This will be reworked into a general feature, for now use this for testing. + * + * @todo implement a general feature + */ + const instanceName = drupalSettings.helfi_instance_name; + if (instanceName === 'asuminen' && Drupal.cookieConsent.getConsentStatus(['statistics'])) { const getViewportWidth = () => window.innerWidth; const getViewportHeight = () => window.innerHeight; const getLanguage = () => document.querySelector('html')?.attributes?.lang?.value || 'unkown'; @@ -31,7 +35,7 @@ const u='//webanalytics.digiaiiris.com/js/'; _paq.push(['setTrackerUrl', `${u}tracker.php`]); _paq.push(['setSiteId', '141']); - _paq.push(['addTracker', `${u}tracker.php`], siteId); + _paq.push(['addTracker', `${u}tracker.php`], '1098'); const d=document; const g=d.createElement('script'); const s=d.getElementsByTagName('script')[0]; // Consider integrity hash check g.async=true; g.src=`${u}piwik.min.js`; s.parentNode.insertBefore(g,s); From d2d79d9cd95f3e8214705f594ee75f8ef9b7f8d9 Mon Sep 17 00:00:00 2001 From: Jere Ljungberg Date: Fri, 14 Feb 2025 16:20:32 +0200 Subject: [PATCH 4/4] Fix function call --- dist/js/matomo.min.js | 2 +- src/js/matomo.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/js/matomo.min.js b/dist/js/matomo.min.js index a7b37e463..ae6d94cdd 100644 --- a/dist/js/matomo.min.js +++ b/dist/js/matomo.min.js @@ -1 +1 @@ -!function(){function e(){let e=null;window.innerWidth?e=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?e=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(e=document.body.clientWidth),"number"==typeof e&&(e=10*Math.round(e/10));let t=null;return window.innerHeight?t=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?t=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(t=document.body.clientHeight),"number"==typeof t&&(t=10*Math.round(t/10)),`${e}x${t}`}!function(t,Drupal){function n(){if("asuminen"===drupalSettings.helfi_instance_name&&Drupal.cookieConsent.getConsentStatus(["statistics"])){const t=()=>window.innerWidth,n=()=>window.innerHeight,i=()=>document.querySelector("html")?.attributes?.lang?.value||"unkown",o=()=>document.querySelector('meta[property="article:published_time"]')?.content||"",s=()=>document.querySelector('meta[property="og:updated_time"]')?.content||"",a=window._paq=window._paq||[];a.push(["setExcludedQueryParams",["maintheme","channeltype","errandservicetype","targetgroup","year","doc","ls","vdoc","dkey","pno","dir","buttonName","familyIncome","fulltime","daysoff","familySize","submitButton","cn","pd","sivu","tyoPaikkaAla","HELP_MODE","tyoSanaHakuKentta","SHOW_TOOLS","haeTyopaikkojaBTN","nayta-kesa","redir","chatMode","id","Id","feedbackId","fid","up","p","c","tyoSuhtTyyppi","kielisyys","cityarea","selection","contentViewMode","v","INFO_MODE","EDIT_MODE","PAGE_MODES","showyears","categories","categories2","MOD","newfeatures","format","contentID","useDefaultText","useDefaultDesc","li_fat_id","lmod","CACHEID","__FB_PRIVATE_TRACKING__","as_qdr","as_occt","as_q","contentIDR","id-2939","redir3","urile","sa","ved","resetButton","hcb","cep","service_node","setlanguage","continueFlag","nayta-kaikki","trk","existed","logout","attachedData","next","ref_ttesl_hdh_ep1","sort","customerid","CVID","amp","1dmy","osoite","mailto","Siirtyy%20jaoston%20päätösasiakirjoihin.","Siirtyy%20sivutossa%20jaoston%20päätösasiakirjojen%20kohtaan.","v:file","v:state","btnG","current","readclass","safe","/'javascript:?%27%20class=%27ch2-open-settings-btn%27%20onClick=%27cookiehub.openSettings()%27","row","start","end","mode","zarsrc","gws_rd","showfromdate","^.*\\@hel.fi$","' class","%27%20class","class","_sm_au_","action","Siirtyy jaoston päätösasiakirjoihin.","Siirtyy sivutossa jaoston päätösasiakirjojen kohtaan.","ISCI","usein kysyttyä palveluverkkosuunnittelusta","Pelastussuunnitelma","Palotarkastus","recepient","Action","amp;current","XIe","dNe","mc_cid","mc_eid","added","client-request-id","estsrequest","ceid","emid","crmid","identify","elq","elqaid","elqat","classId","assignmentId","gidzl","_hsmi","_hsenc","tre","trete","pe_data","o4e","n4e","check_logged_in","code","u4e","itok","WCM_PORTLET","SessionExpired","KYe","WCM_GLOBAL_CONTEXT","frosmo","C_e","name","state","ttclid","acaToken","wvstest","max-depth","__proto__[crVsaSZqMnW4EqBoI22emA]","__proto__.crVsaSZqMnW4EqBoI22emA","constructor.prototype[crVsaSZqMnW4EqBoI22emA]","constructor.prototype.crVsaSZqMnW4EqBoI22emA","constructor[prototype][crVsaSZqMnW4EqBoI22emA]","gsid","fbclid","time","complianz_scan_token","complianz_id"]]),a.push(["setCustomDimension",2,t()]),a.push(["setCustomDimension",3,n()]),a.push(["setCustomDimension",4,i()]),a.push(["setCustomDimension",5,o()]),a.push(["setCustomDimension",6,s()]),a.push(["setCustomDimension",7,e()]),a.push(["trackPageView"]),a.push(["enableLinkTracking"]),function(){const e="//webanalytics.digiaiiris.com/js/";a.push(["setTrackerUrl",`${e}tracker.php`]),a.push(["setSiteId","141"]),a.push(["addTracker",`${e}tracker.php`],"1098");const t=document,n=t.createElement("script"),i=t.getElementsByTagName("script")[0];n.async=!0,n.src=`${e}piwik.min.js`,i.parentNode.insertBefore(n,i)}()}else if(Drupal.cookieConsent.getConsentStatus(["statistics"])){(window._mtm=window._mtm||[]).push({"mtm.startTime":(new Date).getTime(),event:"mtm.Start"});const e=document,t=e.createElement("script"),n=e.getElementsByTagName("script")[0];t.type="text/javascript",t.async=!0,t.src="//webanalytics.digiaiiris.com/js/container_X3dUNyXY.js",n.parentNode.insertBefore(t,n)}}Drupal.cookieConsent.initialized()?n():Drupal.cookieConsent.loadFunction(n)}(jQuery,Drupal)}(); \ No newline at end of file +!function(){function e(){let e=null;window.innerWidth?e=window.innerWidth:document.documentElement&&document.documentElement.clientWidth?e=document.documentElement.clientWidth:document.body&&document.body.clientWidth&&(e=document.body.clientWidth),"number"==typeof e&&(e=10*Math.round(e/10));let t=null;return window.innerHeight?t=window.innerHeight:document.documentElement&&document.documentElement.clientHeight?t=document.documentElement.clientHeight:document.body&&document.body.clientHeight&&(t=document.body.clientHeight),"number"==typeof t&&(t=10*Math.round(t/10)),`${e}x${t}`}!function(t,Drupal){function n(){if("asuminen"===drupalSettings.helfi_instance_name&&Drupal.cookieConsent.getConsentStatus(["statistics"])){const t=()=>window.innerWidth,n=()=>window.innerHeight,i=()=>document.querySelector("html")?.attributes?.lang?.value||"unkown",o=()=>document.querySelector('meta[property="article:published_time"]')?.content||"",s=()=>document.querySelector('meta[property="og:updated_time"]')?.content||"",a=window._paq=window._paq||[];a.push(["setExcludedQueryParams",["maintheme","channeltype","errandservicetype","targetgroup","year","doc","ls","vdoc","dkey","pno","dir","buttonName","familyIncome","fulltime","daysoff","familySize","submitButton","cn","pd","sivu","tyoPaikkaAla","HELP_MODE","tyoSanaHakuKentta","SHOW_TOOLS","haeTyopaikkojaBTN","nayta-kesa","redir","chatMode","id","Id","feedbackId","fid","up","p","c","tyoSuhtTyyppi","kielisyys","cityarea","selection","contentViewMode","v","INFO_MODE","EDIT_MODE","PAGE_MODES","showyears","categories","categories2","MOD","newfeatures","format","contentID","useDefaultText","useDefaultDesc","li_fat_id","lmod","CACHEID","__FB_PRIVATE_TRACKING__","as_qdr","as_occt","as_q","contentIDR","id-2939","redir3","urile","sa","ved","resetButton","hcb","cep","service_node","setlanguage","continueFlag","nayta-kaikki","trk","existed","logout","attachedData","next","ref_ttesl_hdh_ep1","sort","customerid","CVID","amp","1dmy","osoite","mailto","Siirtyy%20jaoston%20päätösasiakirjoihin.","Siirtyy%20sivutossa%20jaoston%20päätösasiakirjojen%20kohtaan.","v:file","v:state","btnG","current","readclass","safe","/'javascript:?%27%20class=%27ch2-open-settings-btn%27%20onClick=%27cookiehub.openSettings()%27","row","start","end","mode","zarsrc","gws_rd","showfromdate","^.*\\@hel.fi$","' class","%27%20class","class","_sm_au_","action","Siirtyy jaoston päätösasiakirjoihin.","Siirtyy sivutossa jaoston päätösasiakirjojen kohtaan.","ISCI","usein kysyttyä palveluverkkosuunnittelusta","Pelastussuunnitelma","Palotarkastus","recepient","Action","amp;current","XIe","dNe","mc_cid","mc_eid","added","client-request-id","estsrequest","ceid","emid","crmid","identify","elq","elqaid","elqat","classId","assignmentId","gidzl","_hsmi","_hsenc","tre","trete","pe_data","o4e","n4e","check_logged_in","code","u4e","itok","WCM_PORTLET","SessionExpired","KYe","WCM_GLOBAL_CONTEXT","frosmo","C_e","name","state","ttclid","acaToken","wvstest","max-depth","__proto__[crVsaSZqMnW4EqBoI22emA]","__proto__.crVsaSZqMnW4EqBoI22emA","constructor.prototype[crVsaSZqMnW4EqBoI22emA]","constructor.prototype.crVsaSZqMnW4EqBoI22emA","constructor[prototype][crVsaSZqMnW4EqBoI22emA]","gsid","fbclid","time","complianz_scan_token","complianz_id"]]),a.push(["setCustomDimension",2,t()]),a.push(["setCustomDimension",3,n()]),a.push(["setCustomDimension",4,i()]),a.push(["setCustomDimension",5,o()]),a.push(["setCustomDimension",6,s()]),a.push(["setCustomDimension",7,e()]),a.push(["trackPageView"]),a.push(["enableLinkTracking"]),function(){const e="//webanalytics.digiaiiris.com/js/";a.push(["setTrackerUrl",`${e}tracker.php`]),a.push(["setSiteId","141"]),a.push(["addTracker",`${e}tracker.php`,"1098"]);const t=document,n=t.createElement("script"),i=t.getElementsByTagName("script")[0];n.async=!0,n.src=`${e}piwik.min.js`,i.parentNode.insertBefore(n,i)}()}else if(Drupal.cookieConsent.getConsentStatus(["statistics"])){(window._mtm=window._mtm||[]).push({"mtm.startTime":(new Date).getTime(),event:"mtm.Start"});const e=document,t=e.createElement("script"),n=e.getElementsByTagName("script")[0];t.type="text/javascript",t.async=!0,t.src="//webanalytics.digiaiiris.com/js/container_X3dUNyXY.js",n.parentNode.insertBefore(t,n)}}Drupal.cookieConsent.initialized()?n():Drupal.cookieConsent.loadFunction(n)}(jQuery,Drupal)}(); \ No newline at end of file diff --git a/src/js/matomo.js b/src/js/matomo.js index b85998a08..05e8713c6 100644 --- a/src/js/matomo.js +++ b/src/js/matomo.js @@ -35,7 +35,7 @@ const u='//webanalytics.digiaiiris.com/js/'; _paq.push(['setTrackerUrl', `${u}tracker.php`]); _paq.push(['setSiteId', '141']); - _paq.push(['addTracker', `${u}tracker.php`], '1098'); + _paq.push(['addTracker', `${u}tracker.php`, '1098']); const d=document; const g=d.createElement('script'); const s=d.getElementsByTagName('script')[0]; // Consider integrity hash check g.async=true; g.src=`${u}piwik.min.js`; s.parentNode.insertBefore(g,s);