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.

NOTE: In order for this to work, you first must have the segment javascript snippet Analytics.js setup and installed on your site. See Segment Quickstart for details in case you don't know. We leverage the segment id to tie chat events to the segment user.

Here is how to enable the Segment integration in Chatlio:

  1. Log in to https://segment.com/ and click on the appropriate source.
  2. On the “Settings” tab, select API Keys on the left and then copy the “Write Key”. Chatlio segment integration
  3. Open the Chatlio dashboard.
  4. Select the widget on which you would like to enable Segment.
  5. 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: '[email protected]'
    });
});

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",
  },
})
:(
Your browser is out-of-date!

This website is built using latest technogies. Unfortunately your browser doesn't support those. Please update your browser to view this website correctly. Thank you.Update my browser now