Tracking Hover Events

If you want to track hover events, 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);

Updated 4 months ago

Tracking Hover Events


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.