Knowledge base | mouseflow

Customize Recording Rate Per Page

With Mouseflow, it's easy to set a recording rate if your website experiences a high volume of traffic. It is also possible to set a custom recording rate per page. Simply copy and paste the code below:

<script type="text/javascript">
    function getCookie(cname) {
        var name = cname + "=";
        var ca = document.cookie.split(';');
        for (var i=0;i<ca.length;i++) {
            var c = ca[i];
            while(c.charAt(0) == '') c = c.substring(1);
            if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
        }
        return "";
    }

    // the page you would like to create a custom recording rate for. Update 'mypage' with the pathname for the page.
    if (window.location.pathname.indexOf('mypage') > -1) {

        // the percentage of visitors you want to track on this page (e.g. 10 = 10% sample, 3 = 33% sample, etc.)
        var mfRate = parseInt((Math.random() * 100)) % 10
    } else {
        var mfRate = 0;
    }

    if (mfRate == 0 || getCookie('mf_user')) {
        window._mfq = window._mfq || [];
        (function() {
            var mf = document.createElement("script"); mf.type="text/javascript"; mf.async = true;
            mf.src = "//cdn.mouseflow.com/projects/your-website-id.js";
            document.getElementsByTagName("head")[0].appendChild(mf);
      })();
    }
</script>

You can change 'mypage' to any page and 10 to any preferred value.

Important

Please ensure that the Recording Rate for the website is set to 'All Visits'. You can locate this by picking the website you're interested in from the drop down menu next to the "Help" tab > Click the "Settings" tab on the left hand side > Make sure the "Recording Rate" is 1/1.