I recently looked into this for our agency as well.
Unfortunately, I wasn’t able to track when a visitor actually sent a message. What I was able to do was implement interaction tracking on the chat window itself using the following code (note that this has some customizations for our Google Tag Manager setup).
<script>
window.addEventListener( 'message', function(event) {
if ( event.origin !== 'https://app.hubspot.com' )
return false;
var eventData = JSON.parse(event.data);
if ( eventData.type == 'open-change' ) {
dataLayer.push({
'event': 'Send Event',
'event_category': 'Live Chat',
'event_action': ( eventData.data ) ? 'Opened Chat' : 'Closed Chat',
'event_label': eventData.uuid,
'event_value': 10
});
}
});
</script>
That will push a dataLayer event for opened/closed click interaction, which isn’t perfect, but it’s a start.
HubSpot needs to implement a window message event for “message sent” so we can truely know when a chat has been started (not just assuming a click = a conversation).