Knowledge base | mouseflow

Track Visitors By Specific Device

With Mouseflow, it's easy to track specific devices. If you're only interested in tracking visitors that use their mobile or tablet to access your site, this is easily accomplished with a few of lines of code.

Track Tablet and Mobile Visitors

<script type="text/javascript">
    // Largest screen size to track
    if (window.innerWidth < 1024) {
        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);
       })();
    // Don't forget the closing bracket
    }
</script>

This example tests if the screen size is less than 1024 pixels wide (standard desktop screen width). If it is, a tracking session will start. You can change '1024' to any preferred value, depending on what screen width you're interested in.

Track Tablet Only Visitors

<script type="text/javascript">
    // Range of screen sizes to track
    if (window.innerWidth >= 480 && window.innerWidth < 1024) {
        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);
       })();
    // Don't forget the closing bracket
    }
</script>

This example tests if the screen size is equal to or wider than 480 pixels (standard mobile screen width) and less than 1024 pixels (standard desktop screen width). If it is, a tracking session will start. You can change '480' and '1024' to any preferred value, depending on which screen widths you're interested in.

Track Mobile Only Visitors

<script type="text/javascript">
    // Largest mobile screen size to track
    if (window.innerWidth < 768) {
        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);
        })();
    // Don't forget the closing bracket
    }
</script>

This example tests if the screen size is less than 768 pixels wide (standard tablet screen width). If it is, a tracking session will start. You can change '768' to any preferred value, depending on what screen width you're interested in.

Track Desktop Visitors

<script type="text/javascript">
    // Smallest screen size to track
    if (window.innerWidth >= 1024) {
        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);
       })();
    // Don't forget the closing bracket
    }
</script>

This example tests if the screen size is larger than or equal to 1024 pixels wide (standard desktop screen width). If it is, a tracking session will start. You can change '1024' to any preferred value, depending on what screen width you're interested in.