To integrate Google tag manager,

  • Go to tagmanager.google.com and log in with your credentials

  • Click Admin

  • Click Tags and click New, a window appears

  • Enter the Tag title

  • Click Tag Configuration

  • Select Custom HTML

  • Paste the following widget code in the HTML text area

    <script>
    window.fcSettings = {
    onInit: function() {
    if (typeof(ga) === "function") {
    ga('create', '<GA TRACKING ID>', 'auto', 'FreshchatEvents');
    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>

    <script src='//fw-cdn.com/1*****7/2*****4.js' chat='true'></script>


  • Click Triggering.

  • Select All Pages

  • Click Save. You will be redirected to Workspace.

  • Click Submit. The Submit Changes window appears.

  • Enter the Version Name and Version Description.

  • Click Publish.


You can also refer to the following video, which demonstrates the above steps.


Note: The above video is only for your reference on where to add the code. It does not contain the code itself. Please refer the link in Step 7 for the actual code.