How to track Live Chat events in Google Analytics

If you want to track conversions in your Google Analytics dashboard when someone opens a new conversation, you can follow this tutorial here. 


First of all, identify your Google Analytics integration you are using. 


There are three different Google Analytics integration snippets:

  • analytics.js
  • gtm.js
  • ga.js


For each of them, you will have to follow their tutorials to track events.

Please identify your own integration and follow the right following step based on yours.


Let's say you want to track conversions when you get a new lead from the live chat, this is how should be implemented.


Analytics.js Live Chat conversion

If you are using the Analytics.js tracking code follow this Google tutorial here to understand how to track events. The following example will trigger an event when a lead has been collected. 


customerly.load({
      app_id: "REPLACE_APP_ID",
      
      callbacks: {
        onLeadGenerated: function( email ) { 
           ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
        }
      }
});



gtag.js Live Chat conversion 

If you are using gtag.js then this is the following event to track conversions. Please refer to the official Google tutorial here


customerly.load({
      app_id: "REPLACE_APP_ID",
      
      callbacks: {
        onLeadGenerated: function( email ) {
            gtag('event', 'conversion', {'send_to': 'AW-CONVERSION_ID/CONVERSION_LABEL',
            'value': 1.0,
            'currency': 'USD'
            });
        }
      }
  
});



ga.js Live Chat conversion

If you are still using the deprecated ga.js version then you can integrate the snippet in this way to track events. Please refer to Google tutorial to understand event tracking with ga.js.



customerly.load({
      app_id: "REPLACE_APP_ID",
      
      callbacks: {
        onLeadGenerated: function( email ){
          _trackEvent(category, action, opt_label, opt_value, opt_noninteraction);
        }
      }
  
});



To find out about all the other callbacks you can use please refer to the live chat callbacks tutorial here.