Event-based tags like clicks and hovers over visible elements on your page can be very easily set up using the Custom Tags picker. Alternatively, adding other types of custom tags or creating tags manually requires a bit of coding.

If you have installed Mouseflow through Google Tag Manager (GTM), see our guide on setting up such tags in GTM instead.

Adding a Single Tag Using the Tracking Code

To push a tag, add the following line to your tracking code:

window._mfq.push(["tag","my-tag"]);

Set the "my-tag" part to match your requirements, accordingly.

Here's an example:

<script type="text/javascript"> 
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);
})();
window._mfq.push(["tag","my-tag"]);
</script>

Adding Multiple Tags Using the Tracking Code

To push multiple tags, just add additional lines. Set the "my-tag" part to match your requirements, accordingly.

Here's an example:

<script type="text/javascript"> 
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);
})();
window._mfq.push(["tag","my-tag"]);
window._mfq.push(["tag","my-other-tag"]);
</script>

Adding a Tag Separate from the Tracking Code

If you want to add a tag without changing your tracking code, you'll just need to enter a short snippet of code. This may come in handy if you are using Google Tag Manager or another extension.

Here's an example:

<script type="text/javascript"> 
window._mfq = window._mfq || [];
window._mfq.push(["tag","my-tag"]);
</script>

Notes

  • The URL on the "mf.src" line must be customized to match the tracking code in your account. In particular, "your-website-id.js" should be replaced with a unique ID for your website.

  • You should always test the solution to make sure it has the desired functionality.

Did this answer your question?