Track your form using custom analytics

Markdown

View as Markdown

At the moment, you can track your form using Google Analytics and Meta Pixel. If you wish to track the form using custom analytics, then you can do this using the JavaScript method collectchat.on. You can track four possible events inside the form.

When form widget opens

<script>
var collectchat = window.collectchat || {};
collectchat.ready = function() {
    collectchat.on('open', function() {
        console.log('User just opened the form widget');
        /* Call your custom analytics function */
    });
}
</script>

When form widget closes

<script>
var collectchat = window.collectchat || {};
collectchat.ready = function() {
    collectchat.on('close', function() {
        console.log('User just closed the form widget');
        /* Call your custom analytics function */
    });
}
</script>

When user completes the conversation

<script>
var collectchat = window.collectchat || {};
collectchat.ready = function() {
    collectchat.on('complete', function() {
        console.log('User just completed the conversation');
        /* Call your custom analytics function */
    });
}
</script>

When user responds to a message

<script>
var collectchat = window.collectchat || {};
collectchat.ready = function() {
  collectchat.on('message', function(details) {
    console.log('User responded to question', details.question, details.answer);
    /* Call your custom analytics function */
  });
}
</script>

Was this article helpful?

Still need help?

Contact us