--- title: "GoogleAnalytics" slug: "googleanalytics" updated: 2025-10-09T11:02:15Z published: 2025-10-09T11:02:15Z canonical: "learn.servitly.com/googleanalytics" --- > ## Documentation Index > Fetch the complete documentation index at: https://learn.servitly.com/llms.txt > Use this file to discover all available pages before exploring further. # GoogleAnalytics To interact with Google Analytics, you can leverage the class `GoogleAnalytics` which is available in the JavaScript context. It provides methods to register and interact with Google Analytics 4. Here is a sample code about class usage: ```javascript const gaTracker = GoogleAnalyticsTracker.create({"tagManagerId": ""}); // event logging a widget has been viewed gaTracker.logEvent("abc-widget viewed"); // set properties you can use to segment users gaTracker.setUserPropertiesReader(function(user) {    return {"persona": (user.organizationId || user.partnerId) ? "SERVICE" : "CUSTOMER"}; }); ```