With Mouseflow, you can choose to only record visitors who perform a specific action - like logging in, adding an item to the cart, or simply clicking a button.

This requires the use of cookies and JavaScript to conditionally include the tracking code. The examples below rely on the js-cookie library. Add this line to use it on your site:

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


<script type="text/javascript">
    window._mfq = window._mfq || [];
    var activateMouseflow = function() { 
        var mf = document.createElement("script"); mf.type = "text/javascript"; mf.async = true; 
        mf.src = "//cdn.mouseflow.com/projects/your-website-id.js";

    // Action to trigger Mouseflow here:
    $("#example").click(function() {
        Cookies.set('mf_start', '1');

    if (Cookies.get('mf_start') === '1') {


  • The URL on the "mf.src" line must be customized to match the tracking code in your account.
  • You should always test these examples to make sure they have the desired functionality.