To integrate Google tag manager,


  1. Go to tagmanager.google.com and login with your credentials.

  2. Click Admin.

  3. Click Tags and click New. A window appears.

  4. Enter the Tag title.

  5. Click Tag Configuration.

  6. Select Custom HTML.

  7. 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> 



  8. Click Triggering.

  9. Select All Pages

  10. Click Save. You will be redirected to Workspace.

  11. Click Submit. The Submit Changes window appears.

  12. Enter the Version Name and Version Description.

  13. Click Publish.


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

https://www.useloom.com/share/2cc5e1ed1c13428baf7158775d87c6bb


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.