# Track your form using custom analytics

At the moment, you can track your form using Google Analytics
[https://collect.chat/help/article/1022-google-analytics] and Meta Pixel
[https://collect.chat/help/article/1023-facebook-pixel]. If you wish to track
the form using custom analytics, then you can do this using the JavaScript
method collectchat.on
[https://developers.collect.chat/#/callbacks?id=collectchatonevent-function].
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>