diff --git a/dist/js/matomo.min.js b/dist/js/matomo.min.js index 5a37c30cd..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(){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(){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 bd0ed8118..05e8713c6 100644 --- a/src/js/matomo.js +++ b/src/js/matomo.js @@ -1,14 +1,15 @@ // 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. + * 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 useJSAPI = window.location.search === '?9mt5bfb2bGk='; - if (useJSAPI) { - // eslint-disable-next-line no-console - console.info('Using JavaScript Tracking'); + 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'; @@ -34,14 +35,14 @@ const u='//webanalytics.digiaiiris.com/js/'; _paq.push(['setTrackerUrl', `${u}tracker.php`]); _paq.push(['setSiteId', '141']); + _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); })(); } - - // 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 || []);