Articles in this section

Track Chat Widget Activity Using Google Analytics 4 (GA4)

Track Chat Widget Activity Using Google Analytics 4 (GA4)

Connect your Enrollio Chat Widget with Google Analytics 4 to monitor how prospective families interact with your chat across enrollment pages, landing pages, and your enrollment site.

What is Chat Widget GA4 Tracking?

Your Enrollio Chat Widget can be embedded across your enrollment pages and website. By integrating GA4 (Google Analytics), you track parent interactions with the Chat Widget, giving you better insights into engagement and conversion behavior.

Key Benefits of GA4 Tracking for Chat Widget

  • Enhanced Parent Insights: Monitor how prospective families interact with your chat to optimize your response strategies
  • Performance Monitoring: Identify and address potential issues in the chat experience
  • Data-Driven Decisions: Leverage analytics to make informed decisions about chat functionalities
  • Seamless Integration: Combine Chat Widget and GA4 scripts without conflicts

Integrate Chat Widget with GA4 Tracking

Make sure Google Analytics 4 (GA4) is already installed on your enrollment site or landing page where your Chat Widget will appear. No additional configuration is required for the Chat Widget to send events to GA4.

Follow these steps to install GA4 tracking, embed the chat widget, and begin capturing analytics events related to widget usage.

Step 1: Add GA4 Global Site Tag

Embed the following code in the <head> section of your webpage or in a GTM Custom HTML tag.

<!-- Google Analytics 4 Global Site Tag -->
<script async src="https://www.googletagmanager.com/gtag/js?id=your-GA-code"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'your-GA-code');
</script>
Important: This script loads the GA4 library and initializes it using your GA4 measurement ID: your-GA-code. The dataLayer is used for storing events and sending them to GA4.

[SCREENSHOT: Show the Settings area in Enrollio where users would access the custom code section to add the GA4 tracking script to their enrollment pages/sites]

Step 2: Embed the Chat Widget

Insert this snippet in the <body> section of your site to load the chat widget.

<!-- Chat Widget Embed - COPY THE CODE FROM YOUR CLIENT ACCOUNT FOR GOOGLE TAG MANAGER (GTM) -->
<div data-chat-widget data-widget-id="widget-id" data-location-id="location-id"></div>
<script src="https://widgets.leadconnectorhq.com/loader.js" 
        data-resources-url="https://widgets.leadconnectorhq.com/chat-widget/loader.js" 
        data-widget-id="widget-id">
</script>

Click on the "Get Code" button, then navigate to the "Via GTM" section to find this snippet.

Attributes Breakdown:

  • data-widget-id: Unique identifier for your widget
  • data-location-id: Corresponds to your Client Account

[SCREENSHOT: Show the Chat Widget settings page with the "Get Code" button highlighted and the GTM tab selected]

Step 3: Add GA4 Custom Event Tracking Script

Paste this script below your chat widget embed to enable event tracking for widget interactions.

<script>
function trackGAEvent(eventName, label) {
  gtag('event', eventName, {
    event_category: 'Chat',
    event_label: label
  });
}

function beforeSubmit(values, host) {
  trackGAEvent('form-submit', 'Form Submitted');
  return true;
}

window.addEventListener("LC_chatWidgetLoaded", function(e) {
  var observer = new MutationObserver(function() {
    if (leadConnector.chatWidget.isActive()) {
      trackGAEvent('widget-open', 'Widget Open');
    } else {
      trackGAEvent('widget-close', 'Widget Close');
    }
  });
  observer.observe(e.detail, {attributes: true});
  window.leadConnector.chatWidget.registerBeforeSubmit(beforeSubmit);
}, false);
</script>

Event Reference for GA4

Understanding what each event tracks helps you validate and use the data more effectively in GA4.

Event Name Trigger Condition Category Label
widget-open When the widget is opened Live Chat Widget Open
widget-close When the widget is closed Live Chat Widget Close
form-submit When a chat form is submitted Live Chat Form Submitted

Testing & Debugging Tips

Use these techniques to confirm your event tracking is correctly set up and working in real time:

  • Google Tag Assistant Extension: Monitor events as you interact with the widget
  • GA4 DebugView: Track real-time events in your Google Analytics dashboard
  • Network Logs: Use browser DevTools → Network tab to verify event payloads
  • Live Test: Open, close, and submit the chat form to validate the respective events

[SCREENSHOT: Show GA4 DebugView with Chat Widget events appearing in real-time]

Pro Tip: Test your tracking immediately after setup by opening and closing the chat widget a few times, then checking GA4 DebugView within a few minutes to confirm events are firing correctly.

Frequently Asked Questions

Will this track parents across all pages?

Yes, as long as the widget and tracking script are embedded on those pages.

Can I customize the events tracked by the Chat Widget?

Currently, the Chat Widget tracks a predefined set of events. Custom event tracking is not supported.

Where can I view the Chat Widget events in GA4?

Navigate to the "Events" section in your GA4 property to view the tracked Chat Widget events.

Related Articles

  • How to Install Enrollio's Chat Widget
  • Getting Started with Chat Widget
  • Google Analytics 4 Tracking
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.