Chatlio Segment Integration
Integrating Chatlio with Segment and Google Analytics
If you use Segment for user analytics, Chatlio provides built in support for sending chat related events to Segment to give you a full picture of activity on your site including live chat.
Here are the events currently sent by Chatlio to Segment:
- Live Chat Conversation Started
- Live Chat Conversation Ended
- Live Chat Message Sent
- Live Chat Message Received
Chatlio automatically ties these events together with other activity on your site using the visitor id.
In the example image below you can see how Segment traces a visitor navigating https://chatlio.com, browsing through a few documentation pages and then asking a question using the live chat widget and finally decides to sign up.
Here is how to enable the Segment integration in Chatlio:
- Log in to https://segment.com/ and click on the appropriate source.
- On the “Settings” tab, select API Keys on the left and then copy the “Write Key”.
- Open the Chatlio dashboard.
- Select the widget on which you would like to enable Segment.
- On the Behavior tab, add your Segment write key to the “Segment integration” field in the “Webhooks and post-chat actions” section.
Out of the box, Chatlio will send the events using an AnonymousID. So if you know who your user is and you want Chatlio to pass that information along to Segment, you can call Chatlio’s identify() method when the widget is ready. Then Chatlio will send your user’s unique ID in the event payloads.
Here is an example of Chatlio’s identify() method:
document.addEventListener('chatlio.ready', function(e) {
window._chatlio.identify('paddys9876', {
name: 'Frank Reynolds',
email: 'freynolds@paddys.com'
});
});
Here is the resulting payload sent to Segment (notice the UserId is what was passed in for the first param of the above identify() call):
client.Track(&analytics.Track{
AnonymousId: "43b6af52-c2cb-4668-88bc-add80e1bbd7c",
UserId: "paddys9876",
Event: "Live Chat Conversation Started",
Properties: map[string]interface{}{
"agent_id": "",
"agent_name": "unknown u.",
"agent_username": "unknown",
"conversation_duration": 0,
"conversation_id": "b11bf805-af57-4421-7744-95333bcbd416",
"message_id": "1705685182.238979",
},
})