Versions Compared

Key

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

...

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 mf = document.createElement("script"); mf.type = "text/javascript"; mf.async = true;
        var currentHostname = window.location.hostname;

       var currentPathname = window.location.pathname;
         // Check whether intranet or www
        if (currentHostname.indexOf("intranet") >= 0 // On intranet
            || currentPathname.indexOf("/staff/") === 0 // 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 regular mouseflow");
            mf.src = "//cdn.mouseflow.com/projects/4a7ff1cf-f5b8-4dd8-95da-13bfe4f4e580.js";
        }


        // var mouseflowPath = window.location.hostname + window.location.pathname; // Set as default. Excludes all query strings

    // 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) {
  
         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);
    }

    }

mouseflowPath = currentHostname + currentPathname;
    console.log("mouseflowPath: " + mouseflowPath);

    (function () {
        var mouseflowPath = currentHostname + currentPathname; mf = document.createElement("script"); mf.type = "text/javascript"; mf.async = true;

        // Check whether intranet or www
        if (currentHostname.indexOf("intranet") >= 0 // On intranet
            || currentPathname.indexOf("/staff/") === 0 // 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("mouseflowPath:Load regular mouseflow" + mouseflowPath));
            mf.src = "//cdn.mouseflow.com/projects/4a7ff1cf-f5b8-4dd8-95da-13bfe4f4e580.js";
        }
        console.log(mf);
        // document.getElementsByTagName("head")[0].appendChild(mf);
    })();

</script>