How to set up Google Analytics with Dixa Messenger

  • Last updated on January 2, 2025 at 10:13 AM

Setting up Google Analytics can help you merge the insight of user behavior on your site. Linking Conversations and User interactions to other KPI can aid in understanding the journeys of your users and how the users reaching out to you through Dixa Messenger compare to those who don't. 

Whether your key KPIs are purchased, retention, churn, or basket size, decorating those with Customer Service metric can be key in understanding how your customer service is performing and help you improve.

How it works

Dixa Messenger can emit events from various actions on the individual user's interaction. This event can then be subscribed to and sent to your Google Analytics account to match user sessions 

The following event can be subscribed to:

'on-widget-open-changed'
'on-conversation-started'
'on-conversation-ended'
'on-message-added'
'on-view-changed'
'on-user-identity-changed'
'on-agent-assigned'
'on-agent-unassigned'
'on-user-purged'
'on-widget-focus-changed'

A Description of the various events


on-widget-open-changed
Is the event of the Dixa Messenger being opened.

on-conversation-started
Is the event of a conversation being started with the Dixa Messenger

on-conversation-ended
Is the event of a conversation being closed in Dixa Messenger

on-message-added
Is the event of a new message being added to the conversation. This can be both agent and user.

on-view-changed
Is the event of the Dixa Messenger changing its view, e.g from main page to conversation page etc.

on-user-identity-changed
Is the event of a user logging into the Dixa Messenger, this can be done either in the initialization phase of the Messenger, or if the setting to require users to log is switched on, and the User is adding their credentials to the Dixa Messenger session

on-agent-assigned
Is the event of an agent joining the conversation. This event can help you identify in Google Analytics what user sessions an agent picked up the conversation, as opposed to e.g. self-serve

on-agent-unassiged
Is the event of an agent being unassigned to a conversation. This happens when the conversation is closed by the agent, or if the conversation is taken over by another agent.

on-user-purged
Is the event of a user being purged or logged out of the Dixa Messenger session. E.g. this could be when a user logs out of your site and you call the purgeUserIdentity action to also log the user out of the Dixa Messenger. When this occurs the event

on-widget-focus-changed
Is the event of the Dixa Messenger either being focused on the screen or in the event of a user 'defocusing' on the Dixa Messenger to e.g. browse your website. This can give you an indication of whether the user is staying inside the Messenger or going back and forth.

How to setup Google Analytics

First, make sure you have Google Analytics and Dixa Messenger on your website.

Then, add following script to your website code. It is responsible for sending the events to Google Analytics.

<script>
const DixaGaCallbackFunc = function(dixaPayload) {
if (typeof ga === 'function') {
ga('send', 'event', 'dixaMessenger-'+ event.data.content.type, dixaPayload);
} elseif (typeof gtag === 'function') {
gtag('event', 'dixaMessenger-'+event.data.content.type, dixaPayload);
} else {
console.log('Dixa tried to send an event to Google Analytics, but Google Analytics doesn\'t appear to be loaded.');
}
}
window.onload = function() {
_dixa_.addListener('on-widget-open-changed', DixaGaCallbackFunc);
_dixa_.addListener('on-conversation-started', DixaGaCallbackFunc);
_dixa_.addListener('on-conversation-ended', DixaGaCallbackFunc);
_dixa_.addListener('on-message-added', DixaGaCallbackFunc);
_dixa_.addListener('on-view-changed', DixaGaCallbackFunc);
_dixa_.addListener('on-user-identity-changed', DixaGaCallbackFunc);
_dixa_.addListener('on-agent-assigned', DixaGaCallbackFunc);
_dixa_.addListener('on-agent-unassigned', DixaGaCallbackFunc);
_dixa_.addListener('on-user-purged', DixaGaCallbackFunc);
_dixa_.addListener('on-widget-focus-changed', DixaGaCallbackFunc);
}
</script>

Was this article helpful?

Help Center
Username
Dixa Support
System Status
Have a question?
Product Roadmap
Webinar Series
Dixa Academy