We have recently refreshed our branding across our offerings and changed the names of our pricing plans. If you have signed up before Aug 9, 2021, please click Previous plans to view your applicable plans.
We assure you that this change will not impact your product experience, and no action is required on your part.


Use the code below for Google Analytics event tracking with Freshchat :


Code Snippet:


<script src="https://wchat.freshchat.com/js/widget.js"></script>
<script>
window.fcWidget.init({
  token: "WEB_CHAT_TOKEN",
  host: "https://wchat.freshchat.com",

  });
if (typeof(ga) === "function") {
        ga('create', '<GA TRACKING ID>', 'auto', 'FreshchatEvents');
        window.fcWidget.on("widget:loaded", function(resp) {
          window.fcWidget.on("widget:opened", function(resp) {
            ga('FreshchatEvents.send', 'event', 'Freshchat widget', 'GadgetGod', 'Widget Open');
          });
          window.fcWidget.on("widget:closed", function(resp) {
            ga('FreshchatEvents.send', 'event', 'Freshchat widget', 'GadgetGod', 'Widget Close');
          });
          window.fcWidget.on('message:received', function(resp) {
            ga('FreshchatEvents.send', 'event', 'Freshchat widget', 'GadgetGod', 'Received');
          });
          window.fcWidget.on('message:sent', function(resp) {
            ga('FreshchatEvents.send', 'event', 'Freshchat widget', 'GadgetGod', 'Sent');
          });
          window.fcWidget.on('user:statechange', function(resp) {
            if (resp && resp.data && resp.data.userState === "created") {
              ga('FreshchatEvents.send', 'event', 'Freshchat widget', 'GadgetGod', 'User Create');
            }
            if (resp && resp.data && resp.data.userState === "loaded") {
              ga('FreshchatEvents.send', 'event', 'Freshchat widget', 'GadgetGod', 'User Loaded');
            }
            if (resp && resp.data && resp.data.userState === "identified") {
              ga('FreshchatEvents.send', 'event', 'Freshchat widget', 'GadgetGod', 'User Identified');
            }
            if (resp && resp.data && resp.data.userState === "restored") {
              ga('FreshchatEvents.send', 'event', 'Freshchat widget', 'GadgetGod', 'User Restored');
            }
          });
        });
      }
      else {
        console.log('Google Analytics not loaded');
      }
    }
</script>


The above code will load the Freshchat Conversations Widget (web messenger), and only if Google Analytics code is also enabled it will track the following events:

  1. Widget Open
  2. Widget Closed
  3. Messages Sent
  4. Messages Received
  5. User Create
  6. User Loaded
  7. User Identified
  8. User Restored

You only need to replace two parameters in the script - your Web Chat Token and Google Analytics Tracking ID.


Here's an image for your reference where you need to update your Web Chat Token and Google Analytics Tracking ID in the above code snippet.