Knowledge base | mouseflow

How do I track visitors referred by Google AdWords?

With Mouseflow, your visitors coming from Google AdWords links will automatically be tagged with their gclid in our app.

You can also control which visitors get recorded.

To only track visits from Google AdWords, we can check for the "gclid" (Google Click ID). This integration makes use of some extra JavaScript.

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">

if (window.location.href.indexOf('gclid') > -1) { Cookies.set('mf_record_user', '1'); }

if (Cookies.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 Google AdWords (with a gclid URL parameter).