Add an optional callback to _mfq.push
When pushing a custom tag or variable when the user clicks on a link, the mouseflow script doesn't have time to record it before the user navigates to the new page. Adding an optional callback - a bit like what google tag manager allows to do with its dataLayer - would allow us to redirect the user only once we're sure the custom tag or variable has been pushed.
Here's how the code could look like:
$('a').on('click', function(e) {
e.preventDefault();
window._mfq.push(['tag', 'my-custom-tag'], function(){
window.location.href = $(this).attr('href'); // this only runs once the tag is successfully pushed and processed by mouseflow
});
});