With Mouseflow, you can record traffic only from users who enter the site through specific pages. This requires the use of cookies and jQuery to conditionally include the tracking code.


This example uses the js-cookie library which is installed by adding this line:

<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.4/js.cookie.min.js"></script>

Then, replace your existing tracking code with something that follows this format: 

<script type="text/javascript"> 
    window._mfq = window._mfq || [];
    var entryPageToRecord = "/entry-page.html";

    function activateMouseflow() { 
        var mf = document.createElement("script"); 
        mf.type = "text/javascript"; mf.defer = true; 
        mf.src = "//cdn.mouseflow.com/projects/INSERT-YOUR-WEBSITE-ID.js";
        document.getElementsByTagName("head")[0].appendChild(mf); 
    };

    var mfEntryPageCookie = Cookies.get('mf_entrypage'); 
    if (mfEntryPageCookie === null || mfEntryPageCookie === undefined) {
        Cookies.set('mf_entrypage', document.location.pathname);
        mfEntryPageCookie = document.location.pathname; 
    }

    if (mfEntryPageCookie === entryPageToRecord) { 
        activateMouseflow();
    }

</script>

Notes

  • You need to customize the path to the entry page (in this case "/entry-page" above).
  • The URL on the "mf.src" line must be customized to match the tracking code in your account.
  • You should always test this to make sure it has the desired functionality.