Knowledge base | mouseflow

Hubspot Integration

With Mouseflow, it's easy to control whether you track certain visits by altering how the tracking code is executed.

To integrate with Hubspot, we can hook into the hubspotutk cookie to track users by the Hubspot ID in Mouseflow. This integration makes use of our Custom Variables feature.

This integration example uses the js-cookie library. Add it to your site by adding this line:

<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.4/js.cookie.min.js"></script>

Example:

<script type="text/javascript">

    // 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);
    })();

    _mfq.push(["setVariable", "hubspot_id", Cookies.get('hubspotutk')]);
</script>

You can now filter the recording list by the hubspot_id variable. Pick hubspot_id as the key and enter a value for the ID, accordingly.