Search code examples
google-analyticsevent-tracking

How to use Google Analytcis Event Tracking to track clicks on <div> element


I'm new to GA and programming in general, but event tracking has been pretty straightforward until I encountered this div for a find my location button.

This is what I've tried:

<div id="locateButton" onclick="ga('send','event','Map Button','click','Find My Location')"></div>

I also tried using onmouseover but no luck.

Any help is greatly appreciated!


Solution

  • Ended up just putting another div around it and that fixed the issue.