UPDATE:
Actually, digging into this further, tracking when the “conversation is started” is possible.
<script>
window.addEventListener( 'message', function(event) {
if ( event.origin !== 'https://app.hubspot.com' )
return false;
var eventData = JSON.parse(event.data);
var eventAction = false;
switch( eventData.type ) {
case 'closed-welcome-message':
eventAction = 'Closed - Welcome Message';
break;
case 'open-change':
eventAction = ( eventData.data ) ? 'Opened - Window' : 'Closed - Window';
break;
case 'external-api-event':
if ( eventData.data.eventType = 'conversationStarted' )
eventAction = 'Conversation Started';
break;
default:
eventAction = false;
break;
}
if ( eventAction ) {
dataLayer.push({
'event': 'Send Event',
'event_category': 'Live Chat',
'event_action': eventAction,
'event_label': eventData.uuid,
'event_value': 10
});
}
});
</script>
However, there isn’t a way to track when a user provides their email address - which is really when you would truely count a conversation as a “lead” for analytical purposes. So this above script would track the following (assuming you use Google Tag Manager):
- Users who open/close the chat window
- Users who close the chat welcome message (if you’re using one)
- Users who start a new conversation