Mouseflow code breakdown

 

Url aliasing:

Needs to remove /staff/ from intranet pages
remove _nocache
remove all query strings
remove /home
needs to use code 741e0e81-8c7c-4934-a0b3-76f524f9a10a for intranet and 4a7ff1cf-f5b8-4dd8-95da-13bfe4f4e580 for homepage
remove _recache @Andrew Bredenkamp
Combine intranet.wgtn.ac.nz, intranet.wgtn.ac.nz/home, intranet.wgtn.ac.nz/staff, intranet.wgtn.ac.nz/staff/home

 

Test cases:

Test

Should output

Pass/fail

Test

Should output

Pass/fail

https://intranet.wgtn.ac.nz/

intranet.wgtn.ac.nz

 

https://intranet.wgtn.ac.nz/staff

intranet.wgtn.ac.nz

 

https://intranet.wgtn.ac.nz/staff?q=test

intranet.wgtn.ac.nz

 

https://intranet.wgtn.ac.nz/staff/home?q=test

intranet.wgtn.ac.nz

 

https://intranet.wgtn.ac.nz/staff/home/_nocache?q=test

intranet.wgtn.ac.nz

 

https://www.wgtn.ac.nz

www.wgtn.ac.nz

 

https://www.wgtn.ac.nz/staff

www.wgtn.ac.nz/staff

 

https://www.wgtn.ac.nz/students/campus/health/wellbeing/programmes-and-workshops/

www.wgtn.ac.nz/students/campus/health/wellbeing/programmes-and-workshops/

 

https://www.wgtn.ac.nz/students/campus/health/wellbeing/programmes-and-workshops/_nocache

www.wgtn.ac.nz/students/campus/health/wellbeing/programmes-and-workshops/

 

https://www.wgtn.ac.nz/fhss

www.wgtn.ac.nz/fhss

 

https://www.wgtn.ac.nz/fhss/home

www.wgtn.ac.nz/fhss

 

https://www.wgtn.ac.nz/fhss/home/_nocache

www.wgtn.ac.nz/fhss

 

https://www.wgtn.ac.nz/fhss/home/_nocache?q=test

www.wgtn.ac.nz/fhss

 

 

Mouseflow code:

<!--@@ Location of places mouseflow implemented: https://victoriauniversity.atlassian.net/wiki/spaces/BAU/pages/93458019/Mouseflow+tracking+update @@--> <!-- Mouseflow Current 1913605 --> <script type="text/javascript"> const mouseflowAssetId = "%asset_name% %asset_assetid%"; // Used for debugging on the front end var _mfq = _mfq || []; var currentHostname = window.location.hostname; var currentPathname = window.location.pathname; var currentQueries = window.location.search; // Edit path for mouseflowPath // Alias intranet.wgtn.ac.nz/staff to intranet.wgtn.ac.nz ONLY if intranet.wgtn.ac.nz is present if (currentHostname.indexOf("intranet") >= 0 && (currentPathname.indexOf("/staff/") === 0 || currentPathname === "/staff")) { console.log("Removing /staff from mouseflowPath"); currentPathname = currentPathname.substring("/staff".length); } // Remove _nocache if (currentPathname.indexOf("/_nocache") >= 0) { console.log("Remove _nocache from mouseflowPath"); currentPathname = currentPathname.substring(0, currentPathname.indexOf("/_nocache")); } // Remove /home if (currentPathname.search(/\/home$/) >= 0) { console.log("Remove /home from mouseflowPath"); currentPathname = currentPathname.substring(0, currentPathname.search(/\/home$/)); } // As extra precaution, remove trailing / if (currentPathname.charAt(currentPathname.length - 1) === "/") { console.log("Removing trailing / from mouseflowPath"); currentPathname = currentPathname.substring(0, -1); } var mouseflowPath = currentHostname + currentPathname; // This excludes queries. Add + currentQueries to include them // Adding exceptions for staff and student toolbars if (currentQueries.search(/mytools(&|$)/) >= 0) { console.log("Setting mouseflowPath to mytools without path"); mouseflowPath = currentHostname + "?mytools"; } else if (currentQueries.search(/toolbar(&|$)/) >= 0) { console.log("Setting mouseflowPath to toolbar without path"); mouseflowPath = currentHostname + "?toolbar"; } console.log("mouseflowPath: " + mouseflowPath); (function () { var mf = document.createElement("script"); mf.type = "text/javascript"; mf.async = true; // Check whether intranet or www if (window.location.hostname.indexOf("intranet") >= 0 // On intranet || window.location.pathname.indexOf("/staff/") === 0 || window.location.pathname === "/staff" // Catch for some situations where /staff/ is used instead of intranet. E.g. on cms.wgtn.ac.nz ) { console.log("Load intranet mouseflow"); mf.src = "//cdn.mouseflow.com/projects/741e0e81-8c7c-4934-a0b3-76f524f9a10a.js"; } else { console.log("Load wgtn mouseflow"); mf.src = "//cdn.mouseflow.com/projects/4a7ff1cf-f5b8-4dd8-95da-13bfe4f4e580.js"; } console.log(mf); document.getElementsByTagName("head")[0].appendChild(mf); // Adds key to recording with original url if it has been changed if(mouseflowPath !== window.location.href.substring(window.location.protocol.length + 2)) { _mfq.push(["setVariable", 'originalUrl', window.location.href]); } })(); </script>