Mouseflow gives you complete control over what visitors get recorded. For example, you can record only visitors who are using a Tablet.

Setup

To record only visitors using mobile devices such as phones or tablets we can include a check for the visitor's screen size into the Mouseflow tracking code.


1. Log in to your site and locate your Mouseflow Tracking Script

You will usually find your tracking script in the backend of your website.

2. Modify your Mouseflow Tracking Script

You will need to add the following snippet of JavaScript to your existing Mouseflow tracking code:

if (window.innerWidth >= 480 && window.innerWidth < 1024) { 
// Mouseflow Tracking Snippet goes here...
}

This code snippet checks 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.

Note: If you're using Google Tag Manager please see our article on modifying the Mouseflow tracking code in GTM.

An example of the modified Tracking Code would look as follows:

<script type="text/javascript">
if (window.innerWidth >= 480 && window.innerWidth < 1024) {
// mouseflow tracking code
window._mfq = window._mfq || [];
(function() {
var mf = document.createElement("script");
mf.type = "text/javascript"; mf.defer = true;
mf.src = "//cdn.mouseflow.com/projects/your-website-id.js";
document.getElementsByTagName("head")[0].appendChild(mf);
})();
}
</script>

Once you've successfully updated your tracking code on all pages where you want the change to apply, please make sure to save your changes to the code.

Note: Due to browser caching changes to the Tracking Code and Recording Script may take up to 48 hours to take full effect.

Did this answer your question?