Tracking Hover Events

If you want to track hover eventsevents - Actions users take on your site or in your app. Events are the basic building blocks of reports., we recommend that you add an event listener to track them for that element only by using something like the class name to identify it appropriately.

The sample code below can be implemented to capture hover events. It may differ slightly in your implementation depending your specific use case. In this case, you should add a listener for when the user hovers over an element with the .myTooltipClass.

document.addEventListener('mouseover', function(e) {
  if (/myTooltipClass/.test(e.target.className)) {
    heap.track("Tooltip Hover");
  }
}, false);