With Mouseflow, it's easy to control which visitors get recorded. For example, you can record visitors who find your website through a Bing Ad.
To only track visits from Bing Ads, we can check for the "msclkid" (MSN Click ID). This integration makes use of some extra JavaScript. Just replace your tracking code with the snippet below.
Example
<script type="text/javascript">
var Cookie = { set: function(name, value, days) { var domain, domainParts, date, expires, host; if (days) { date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); expires = "; expires="+date.toGMTString(); } else { expires = ""; } host = location.host; if (host.split('.').length === 1) { document.cookie = name+"="+value+expires+"; path=/"; } else { domainParts = host.split('.'); domainParts.shift(); domain = '.'+domainParts.join('.'); document.cookie = name+"="+value+expires+"; path=/; domain="+domain;
if (Cookie.get(name) == null || Cookie.get(name) != value) { domain = '.'+host; document.cookie = name+"="+value+expires+"; path=/; domain="+domain; } } }, get: function(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for (var i=0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') { c = c.substring(1,c.length); } if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; }, erase: function(name) { Cookie.set(name, '', -1); } };
if (window.location.href.indexOf('msclkid') > -1) { Cookie.set('mf_record_user', 1, 10); }
if (Cookie.get('mf_record_user')) {
// mouseflow tracking code
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);
})();
}
</script>
Each new visit will only be captured if it originates from Bing Ads (with a "msclkid" URL parameter).
Tags: track record referral bing ad
Comments