Tracking Gorgias livechat events in Google Analytics

Updated on 2023-06-16

Gorgias is a popular help desk and customer service tool for ecommerce brands.

If your store uses Gorgias you'll want to track how the pre-checkout interactions with support agents drive purchasing, and how the usage of the Gorgias interacts with other customer events in Google Analytics

Tracking Gorgias livechat

Gorgias's livechat widget provides a way to hook into the events, and the script below sends the most common events to Google Analytics:

  • gorgias_widget_opened when the chat widget is opened
  • gorgias_widget_closed when the chat widget is closed
  • gorgias_message_sent when a customer sends a message
  • gorgias_message_received when a customer receives a message

See more ways you can track customer interactions with Gorgias here

Adding the script

You can paste this minified script anywhere into the Shopify theme.liquid file. It waits for the Gorgias widget to load before listening to the events.

var eventsToTrack=[{gorgias:"message:sent",ga:"gorgias_message_sent",},{gorgias:"message:received",ga:"gorgias_message_received",},{gorgias:"widget:opened",ga:"gorgias_widget_opened",},{gorgias:"widget:closed",ga:"gorgias_widget_closed",},];var initGorgiasChatPromise=window.GorgiasChat?window.GorgiasChat.init():new Promise(function(resolve){window.addEventListener("gorgias-widget-loaded",function(){resolve()})});initGorgiasChatPromise.then(function(){eventsToTrack.forEach(function(event){GorgiasChat.on(event.gorgias,function(data){gtag&&gtag("event",})})})

The raw code

Here is the full script if you want to adapt it to track different events or to different data destinations

var eventsToTrack = [
    gorgias: "message:sent",
    ga: "gorgias_message_sent",
    gorgias: "message:received",
    ga: "gorgias_message_received",
    gorgias: "widget:opened",
    ga: "gorgias_widget_opened",
    gorgias: "widget:closed",
    ga: "gorgias_widget_closed",

var initGorgiasChatPromise = window.GorgiasChat
  ? window.GorgiasChat.init()
  : new Promise(function (resolve) {
      window.addEventListener("gorgias-widget-loaded", function () {

initGorgiasChatPromise.then(function () {
  eventsToTrack.forEach(function (event) {
    GorgiasChat.on(event.gorgias, function (data) {
      gtag && gtag("event",;