From d1cc6aa39a5b2c83a397d9ab56b00ab3d5d5fa9f Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Tue, 21 Feb 2017 23:41:11 +1300 Subject: Improvements for tracking of single page applications (#11344) * improve single page website tracking * added docs and minified piwik * Re-generate piwik.js --- piwik.js | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'piwik.js') diff --git a/piwik.js b/piwik.js index 7a1b80a91e..5cbcd0a3fa 100644 --- a/piwik.js +++ b/piwik.js @@ -56,20 +56,21 @@ if(cR){return{type:cR,href:cT}}}}function aF(cR,cS,cT,cU){var cV=t.buildInteract if(cS){cV.push(cS)}}return cV}function cf(cS){var cR=t.collectContent(cS);return bh(cR,cS)}function aX(cS){if(!cS||!cS.length){return[]}var cR;for(cR=0;cR0){cS+="&"}else{cS+="?"}var cU=aN().uuid;var cT=aA();cS=C(cS,an,cU+cT);Y.setAnyAttribute(cR,"href",cS)}function ar(cU){var cV=Y.getAttributeValueFromNode(cU,"href");if(!cV){return false}cV=String(cV);var cS=cV.indexOf("//")===0||cV.indexOf("http://")===0||cV.indexOf("https://")===0; if(!cS){return false}var cR=cU.pathname||b2(cU.href);var cT=(cU.hostname||c(cU.href)).toLowerCase();if(ak(cT,cR)){if(!cl(cw,I(cT))){return true}return false}return false}function ck(cR){var cS=cK(cR);if(cS&&cS.type){cS.href=n(cS.href);cC(cS.href,cS.type,undefined,null,cR);return}if(cp){cR=al(cR);if(ar(cR)){b0(cR)}}}function cc(){return D.all&&!D.addEventListener}function cx(cR){var cT=cR.which;var cS=(typeof cR.button);if(!cT&&cS!=="undefined"){if(cc()){if(cR.button&1){cT=1}else{if(cR.button&2){cT=3}else{if(cR.button&4){cT=2}}}}else{if(cR.button===0||cR.button==="0"){cT=1}else{if(cR.button&1){cT=2}else{if(cR.button&2){cT=3}}}}}return cT}function bA(cR){switch(cx(cR)){case 1:return"left";case 2:return"middle";case 3:return"right"}}function aQ(cR){return cR.target||cR.srcElement}function at(cR){return function(cU){cU=cU||Q.event;var cT=bA(cU);var cV=aQ(cU);if(cU.type==="click"){var cS=false;if(cR&&cT==="middle"){cS=true}if(cV&&!cS){ck(cV)}}else{if(cU.type==="mousedown"){if(cT==="middle"&&cV){aH=cT; -bk=cV}else{aH=bk=null}}else{if(cU.type==="mouseup"){if(cT===aH&&cV===bk){ck(cV)}aH=bk=null}else{if(cU.type==="contextmenu"){ck(cV)}}}}}}function aj(cT,cS){var cR=typeof cS;if(cR==="undefined"){cS=true}ag(cT,"click",at(cS),false);if(cS){ag(cT,"mouseup",at(cS),false);ag(cT,"mousedown",at(cS),false);ag(cT,"contextmenu",at(cS),false)}}function bl(cS){if(!ai){ai=true;var cT,cR=aP(bj,"ignore"),cU=D.links;if(cU){for(cT=0;cT0){cV=parseInt(cV,10); -cY(cV)}})}function cj(){var cS,cU,cV={pdf:"application/pdf",qt:"video/quicktime",realp:"audio/x-pn-realaudio-plugin",wma:"application/x-mplayer2",dir:"application/x-director",fla:"application/x-shockwave-flash",java:"application/x-java-vm",gears:"application/x-googlegears",ag:"application/x-silverlight"};if(!((new RegExp("MSIE")).test(g.userAgent))){if(g.mimeTypes&&g.mimeTypes.length){for(cS in cV){if(Object.prototype.hasOwnProperty.call(cV,cS)){cU=g.mimeTypes[cV[cS]];cH[cS]=(cU&&cU.enabledPlugin)?"1":"0"}}}if(typeof navigator.javaEnabled!=="unknown"&&G(g.javaEnabled)&&g.javaEnabled()){cH.java="1"}if(x(Q.GearsFactory)){cH.gears="1"}cH.cookie=bM()}var cT=parseInt(T.width,10);var cR=parseInt(T.height,10);cH.res=parseInt(cT,10)+"x"+parseInt(cR,10)}cj();a4();aC();this.getVisitorId=function(){return aN().uuid};this.getVisitorInfo=function(){return cq()};this.getAttributionInfo=function(){return bu()};this.getAttributionCampaignName=function(){return bu()[0]};this.getAttributionCampaignKeyword=function(){return bu()[1] -};this.getAttributionReferrerTimestamp=function(){return bu()[2]};this.getAttributionReferrerUrl=function(){return bu()[3]};this.setTrackerUrl=function(cR){av=cR};this.getTrackerUrl=function(){return av};this.addTracker=function(cR,cT){if(!cT){throw new Error("A siteId must be given to add a new tracker")}if(!G(cR)||null===cR){cR=this.getTrackerUrl()}var cS=new N(cR,cT);F.push(cS);return cS};this.getSiteId=function(){return bN};this.setSiteId=function(cR){bK(cR)};this.setUserId=function(cR){if(!G(cR)||!cR.length){return}bi=cR;bw=bO(bi).substr(0,16)};this.getUserId=function(){return bi};this.setCustomData=function(cR,cS){if(S(cR)){ah=cR}else{if(!ah){ah={}}ah[cR]=cS}};this.getCustomData=function(){return ah};this.setCustomRequestProcessing=function(cR){bS=cR};this.appendToTrackingUrl=function(cR){cA=cR};this.getRequest=function(cR){return b9(cR)};this.addPlugin=function(cR,cS){a[cR]=cS};this.setCustomDimension=function(cR,cS){cR=parseInt(cR,10);if(cR>0){if(!G(cS)){cS=""}if(!u(cS)){cS=String(cS) -}a8[cR]=cS}};this.getCustomDimension=function(cR){cR=parseInt(cR,10);if(cR>0&&Object.prototype.hasOwnProperty.call(a8,cR)){return a8[cR]}};this.deleteCustomDimension=function(cR){cR=parseInt(cR,10);if(cR>0){delete a8[cR]}};this.setCustomVariable=function(cS,cR,cV,cT){var cU;if(!G(cT)){cT="visit"}if(!G(cR)){return}if(!G(cV)){cV=""}if(cS>0){cR=!u(cR)?String(cR):cR;cV=!u(cV)?String(cV):cV;cU=[cR.slice(0,be),cV.slice(0,be)];if(cT==="visit"||cT===2){ci();aG[cS]=cU}else{if(cT==="page"||cT===3){bD[cS]=cU}else{if(cT==="event"){b3[cS]=cU}}}}};this.getCustomVariable=function(cS,cT){var cR;if(!G(cT)){cT="visit"}if(cT==="page"||cT===3){cR=bD[cS]}else{if(cT==="event"){cR=b3[cS]}else{if(cT==="visit"||cT===2){ci();cR=aG[cS]}}}if(!G(cR)||(cR&&cR[0]==="")){return false}return cR};this.deleteCustomVariable=function(cR,cS){if(this.getCustomVariable(cR,cS)){this.setCustomVariable(cR,"","",cS)}};this.storeCustomVariablesInCookie=function(){by=true};this.setLinkTrackingTimer=function(cR){br=cR};this.getLinkTrackingTimer=function(){return br -};this.setDownloadExtensions=function(cR){if(u(cR)){cR=cR.split("|")}cG=cR};this.addDownloadExtensions=function(cS){var cR;if(u(cS)){cS=cS.split("|")}for(cR=0;cR1){ad("The method "+ai+' is registered more than once in "_paq" variable. Only the last call has an effect. Please have a look at the multiple Piwik trackers documentation: http://developer.piwik.org/guides/tracking-javascript-guide#multiple-piwik-trackers')}an[ai]++}}}}return am}var z=["addTracker","disableCookies","setTrackerUrl","setAPIUrl","enableCrossDomainLinking","setCookiePath","setCookieDomain","setDomains","setUserId","setSiteId","enableLinkTracking"];function X(ah,aj){var ai=new N(ah,aj);F.push(ai);_paq=b(_paq,z);for(B=0;B<_paq.length;B++){if(_paq[B]){Z(_paq[B])}}_paq=new E();return ai -}ag(Q,"beforeunload",ab,false);Date.prototype.getTimeAlias=Date.prototype.getTime;d={initialized:false,JSON:JSON_PIWIK,DOM:{addEventListener:function(ak,aj,ai,ah){var al=typeof ah;if(al==="undefined"){ah=false}ag(ak,aj,ai,ah)},onLoad:l,onReady:o,isNodeVisible:i,isOrWasNodeVisible:t.isNodeVisible},on:function(ai,ah){if(!v[ai]){v[ai]=[]}v[ai].push(ah)},off:function(aj,ai){if(!v[aj]){return}var ah=0;for(ah;ah0){cV=parseInt(cV,10);cY(cV)}})}function cj(){var cS,cU,cV={pdf:"application/pdf",qt:"video/quicktime",realp:"audio/x-pn-realaudio-plugin",wma:"application/x-mplayer2",dir:"application/x-director",fla:"application/x-shockwave-flash",java:"application/x-java-vm",gears:"application/x-googlegears",ag:"application/x-silverlight"};if(!((new RegExp("MSIE")).test(g.userAgent))){if(g.mimeTypes&&g.mimeTypes.length){for(cS in cV){if(Object.prototype.hasOwnProperty.call(cV,cS)){cU=g.mimeTypes[cV[cS]];cH[cS]=(cU&&cU.enabledPlugin)?"1":"0"}}}if(typeof navigator.javaEnabled!=="unknown"&&G(g.javaEnabled)&&g.javaEnabled()){cH.java="1"}if(x(Q.GearsFactory)){cH.gears="1"}cH.cookie=bM()}var cT=parseInt(T.width,10);var cR=parseInt(T.height,10);cH.res=parseInt(cT,10)+"x"+parseInt(cR,10)}cj();a4();aC();this.getVisitorId=function(){return aN().uuid};this.getVisitorInfo=function(){return cq()};this.getAttributionInfo=function(){return bu() +};this.getAttributionCampaignName=function(){return bu()[0]};this.getAttributionCampaignKeyword=function(){return bu()[1]};this.getAttributionReferrerTimestamp=function(){return bu()[2]};this.getAttributionReferrerUrl=function(){return bu()[3]};this.setTrackerUrl=function(cR){av=cR};this.getTrackerUrl=function(){return av};this.addTracker=function(cR,cT){if(!cT){throw new Error("A siteId must be given to add a new tracker")}if(!G(cR)||null===cR){cR=this.getTrackerUrl()}var cS=new N(cR,cT);F.push(cS);return cS};this.getSiteId=function(){return bN};this.setSiteId=function(cR){bK(cR)};this.setUserId=function(cR){if(!G(cR)||!cR.length){return}bi=cR;bw=bO(bi).substr(0,16)};this.getUserId=function(){return bi};this.setCustomData=function(cR,cS){if(S(cR)){ah=cR}else{if(!ah){ah={}}ah[cR]=cS}};this.getCustomData=function(){return ah};this.setCustomRequestProcessing=function(cR){bS=cR};this.appendToTrackingUrl=function(cR){cA=cR};this.getRequest=function(cR){return b9(cR)};this.addPlugin=function(cR,cS){a[cR]=cS +};this.setCustomDimension=function(cR,cS){cR=parseInt(cR,10);if(cR>0){if(!G(cS)){cS=""}if(!u(cS)){cS=String(cS)}a8[cR]=cS}};this.getCustomDimension=function(cR){cR=parseInt(cR,10);if(cR>0&&Object.prototype.hasOwnProperty.call(a8,cR)){return a8[cR]}};this.deleteCustomDimension=function(cR){cR=parseInt(cR,10);if(cR>0){delete a8[cR]}};this.setCustomVariable=function(cS,cR,cV,cT){var cU;if(!G(cT)){cT="visit"}if(!G(cR)){return}if(!G(cV)){cV=""}if(cS>0){cR=!u(cR)?String(cR):cR;cV=!u(cV)?String(cV):cV;cU=[cR.slice(0,be),cV.slice(0,be)];if(cT==="visit"||cT===2){ci();aG[cS]=cU}else{if(cT==="page"||cT===3){bD[cS]=cU}else{if(cT==="event"){b3[cS]=cU}}}}};this.getCustomVariable=function(cS,cT){var cR;if(!G(cT)){cT="visit"}if(cT==="page"||cT===3){cR=bD[cS]}else{if(cT==="event"){cR=b3[cS]}else{if(cT==="visit"||cT===2){ci();cR=aG[cS]}}}if(!G(cR)||(cR&&cR[0]==="")){return false}return cR};this.deleteCustomVariable=function(cR,cS){if(this.getCustomVariable(cR,cS)){this.setCustomVariable(cR,"","",cS)}};this.deleteCustomVariables=function(cR){if(cR==="page"||cR===3){bD={} +}else{if(cR==="event"){b3={}}else{if(cR==="visit"||cR===2){aG={}}}}};this.storeCustomVariablesInCookie=function(){by=true};this.setLinkTrackingTimer=function(cR){br=cR};this.getLinkTrackingTimer=function(){return br};this.setDownloadExtensions=function(cR){if(u(cR)){cR=cR.split("|")}cG=cR};this.addDownloadExtensions=function(cS){var cR;if(u(cS)){cS=cS.split("|")}for(cR=0;cR1){ad("The method "+ai+' is registered more than once in "_paq" variable. Only the last call has an effect. Please have a look at the multiple Piwik trackers documentation: http://developer.piwik.org/guides/tracking-javascript-guide#multiple-piwik-trackers')}an[ai]++}}}}return am}var z=["addTracker","disableCookies","setTrackerUrl","setAPIUrl","enableCrossDomainLinking","setCookiePath","setCookieDomain","setDomains","setUserId","setSiteId","enableLinkTracking"]; +function X(ah,aj){var ai=new N(ah,aj);F.push(ai);_paq=b(_paq,z);for(B=0;B<_paq.length;B++){if(_paq[B]){Z(_paq[B])}}_paq=new E();return ai}ag(Q,"beforeunload",ab,false);Date.prototype.getTimeAlias=Date.prototype.getTime;d={initialized:false,JSON:JSON_PIWIK,DOM:{addEventListener:function(ak,aj,ai,ah){var al=typeof ah;if(al==="undefined"){ah=false}ag(ak,aj,ai,ah)},onLoad:l,onReady:o,isNodeVisible:i,isOrWasNodeVisible:t.isNodeVisible},on:function(ai,ah){if(!v[ai]){v[ai]=[]}v[ai].push(ah)},off:function(aj,ai){if(!v[aj]){return}var ah=0;for(ah;ah