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
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 openedgorgias_widget_closed
when the chat widget is closedgorgias_message_sent
when a customer sends a messagegorgias_message_received
when a customer receives a messageSee more ways you can track customer interactions with Gorgias here
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.
<script>
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&>ag("event",event.ga)})})})
</script>
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 () {
resolve();
});
});
initGorgiasChatPromise.then(function () {
eventsToTrack.forEach(function (event) {
GorgiasChat.on(event.gorgias, function (data) {
gtag && gtag("event", event.ga);
});
});
});