Search code examples
google-analyticsanalyticsgtag.js

Track Custom event using Google Analytics


I am trying to track user feedback onclick of thumpsUp(1) or thumsDown(0) : enter image description here with help of GA but not able to track the events in the Analytics Dashboard as shown below.

      window.ga("send", {
        hitType: "event",
        eventCategory: "button",
        eventAction: "feedback",
        eventLabel: pageID, // page url
        eventValue: value,  // 1 or 0
      });
    }

custom event is not appearing below:

enter image description here

I am able to get events : enter image description here Is it possible to map vote and pageID together so that we can know which page has which vote

Many Thanks


Solution

  • The code shown is for Universal Analytics but dashboard is on GA4.

    They are 2 different things.

    You can find code to setup GA4 events in the documentation: https://developers.google.com/analytics/devguides/collection/ga4/events?client_type=gtag

    To understand who clicked on up/downvote you can use the parameters associated with the event:

    https://developers.google.com/analytics/devguides/collection/ga4/event-parameters?client_type=gtag

    Note: the data in the GA4 platform (unlike UA) are visible after 24h.