With Mouseflow, you can determine whether to record visitors based on the referral source. This requires JavaScript to conditionally include the tracking code and start the recording.

Record Visits from a Single Referral Source

Replace your existing tracking code with something that follows the below format, for example, if you want to only track referrals from http://example.com

<script>
var mouseflowAutoStart = false;
var referrerDomain = 'example.com';

if (document.referrer.indexOf(referrerDomain) > -1) {
document.cookie = 'mf_record=1;path=/;max-age=' + 60 * 60 * 24;
}
if (document.cookie.indexOf('mf_record=1') > -1) {
mouseflowAutoStart = true;
}
window._mfq = window._mfq || [];
(function() {
var mf = document.createElement("script");
mf.type = "text/javascript"; mf.defer = true;
mf.src = "//cdn.mouseflow.com/projects/<WEBSITE_ID>.js";
document.getElementsByTagName("head")[0].appendChild(mf);
})();
</script>

Note: Replace <WEBSITE_ID> with your own website ID from Mouseflow.

Never Record Visits from a Single Referral Source

Replace your existing tracking code with something that follows the below format, for example, if you never want to track referrals from http://example.com

<script>
var mouseflowAutoStart = false;
var referrerDomain = 'example.com';

if (document.referrer.indexOf(referrerDomain) === -1) {
document.cookie = 'mf_record=1;path=/;max-age=' + 60 * 60 * 24;
}

if (document.cookie.indexOf('mf_record=1') > -1) {
mouseflowAutoStart = true;
}

window._mfq = window._mfq || [];
(function() {
var mf = document.createElement("script");
mf.type = "text/javascript"; mf.defer = true;
mf.src = "//cdn.mouseflow.com/projects/<WEBSITE_ID>.js";
document.getElementsByTagName("head")[0].appendChild(mf);
})();
</script>

Note: Replace <WEBSITE_ID> with your own website ID from Mouseflow.

Exclude Visits From Multiple Referral Sources

<script>
var mouseflowAutoStart = false;
var referrerDomains = ['google.com', 'facebook.com'];
var match = false;

for (var i = 0; i < referrerDomains.length; i++) {
var referrerDomain = referrerDomains[i];

if (document.referrer.indexOf(referrerDomain) > -1) {
match = true;
}
}

if (!match) {
document.cookie = 'mf_record=1;path=/;max-age=' + 60 * 60 * 24;
}

if (document.cookie.indexOf('mf_record=1') > -1) {
mouseflowAutoStart = true;
}

window._mfq = window._mfq || [];
(function() {
var mf = document.createElement("script");
mf.type = "text/javascript"; mf.defer = true;
mf.src = "//cdn.mouseflow.com/projects/<WEBSITE_ID>.js";
document.getElementsByTagName("head")[0].appendChild(mf);
})();
</script>

Note: Replace <WEBSITE_ID> with your own website ID from Mouseflow.

Did this answer your question?