Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  •  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

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

...

Code Block
breakoutModefull-width
languagehtml
<!--@@ 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 || [];

   (function () {
        var mfcurrentHostname = document.createElement("script"); mf.type = "text/javascript"; mf.async = true;
   window.location.hostname;
    var currentHostnamecurrentPathname = window.location.hostnamepathname;
    var  currentQueries  var currentPathname = window.location.pathnamesearch;

    // Edit path for mouseflowPath
    // Check whether intranet or www
   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/") On=== intranet0 || currentPathname === "/staff")) {
       || currentPathnameconsole.indexOflog("Removing /staff/ from mouseflowPath");
  === 0 // Catch for some situationscurrentPathname where= currentPathname.substring("/staff/".length);
is used instead of intranet. E.g. on cms.wgtn.ac.nz}

    // Remove _nocache
   ) {
   if (currentPathname.indexOf("/_nocache") >= 0) {
        console.log("Load intranet mouseflowRemove _nocache from mouseflowPath");
        currentPathname =   mf.src = "//cdn.mouseflow.com/projects/741e0e81-8c7c-4934-a0b3-76f524f9a10a.js"currentPathname.substring(0, currentPathname.indexOf("/_nocache"));
    }
    }// elseRemove {/home
    if (currentPathname.search(/\/home$/) >= 0) {
        console.log("Load regular mouseflowRemove /home from mouseflowPath");
        currentPathname = currentPathname.substring(0, currentPathname.search(/\/home$/));
    }

  mf.src = "//cdn.mouseflow.com/projects/4a7ff1cf-f5b8-4dd8-95da-13bfe4f4e580.js";
    As extra precaution, remove trailing /
    if (currentPathname.charAt(currentPathname.length - 1) === "/") {
        console.log("Removing trailing / from mouseflowPath");
    }    currentPathname = currentPathname.substring(0, -1);
   // Edit}
path
for mouseflowPath   var mouseflowPath = currentHostname + currentPathname; // AliasThis excludes 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/") ===queries. Add + currentQueries to include them
    
    // Adding exceptions for staff and student toolbars
    if (currentQueries.search(/mytools(&|$)/) >= 0) {
            console.log("Removing /staff from mouseflowPathSetting mouseflowPath to mytools without path");
        mouseflowPath = currentHostname + "?mytools";
    } currentPathnameelse =if currentPathname.substring("/staff".length);
  (currentQueries.search(/toolbar(&|$)/) >= 0) {
     }   console.log("Setting mouseflowPath to toolbar without   // Remove _nocachepath");
        mouseflowPath = currentHostname if+ (currentPathname.indexOf("/_nocache") >= 0) {"?toolbar";
    }
    
    console.log("RemovemouseflowPath: _nocache" from+ mouseflowPath");

    (function () {
      currentPathname  var mf = currentPathnamedocument.substring(0, currentPathname.indexOf("/_nocache"));
  createElement("script"); mf.type = "text/javascript"; mf.async = true;

    }    // Check whether intranet or //www
Remove /home         if (currentPathname.search(/\/home$/window.location.hostname.indexOf("intranet") >= 0) { // On intranet
            console.log("Remove /home from mouseflowPath");
            currentPathname = currentPathname.substring(0, currentPathname.search(/\/home$/));|| 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
        ) }{
         // As extra precaution, remove trailing / console.log("Load intranet mouseflow");
         if (currentPathname.charAt(currentPathname.length - 1)mf.src === "/")/cdn.mouseflow.com/projects/741e0e81-8c7c-4934-a0b3-76f524f9a10a.js";

        } else {
            console.log("RemovingLoad trailing / from mouseflowPathwgtn mouseflow");
            currentPathnamemf.src = currentPathname.substring(0, -1)"//cdn.mouseflow.com/projects/4a7ff1cf-f5b8-4dd8-95da-13bfe4f4e580.js";
        }
        console.log(mf);
   var mouseflowPath = currentHostname + currentPathname document.getElementsByTagName("head")[0].appendChild(mf);

        console.log("mouseflowPath: " + mouseflowPath);// Adds key to recording with original url if it has been changed
         console.log(mf);if(mouseflowPath !== window.location.href.substring(window.location.protocol.length + 2)) {
            document_mfq.getElementsByTagNamepush(["head")[0].appendChild(mf);setVariable", 'originalUrl', window.location.href]);
        }
    })();

</script>