
Whichever JavaScript listener you use, you can check your event in the Real-Time reports.
If you’re trying to generate a Google Analytics event based on a click and onclick isn’t working, try onmousedown instead.
Let’s say that you want to track a click on the following mailto: link as a Google Analytics event:
<a href="mailto:service@xyz?subject=Demo%20Request">mailto: link</a>.
If you use the JavaScript onclick handler, make sure to test the event in multiple browsers, because if the “mouseup” part of the click is not recognized, onclick never fires:
<a onclick="ga('send', 'event', 'link', 'mailto', this.href);" href="mailto:service@xyz?subject=Demo%20Request">mailto: link</a>.
If onclick is proving unreliable, use onmousedown instead:
<a onmousedown="ga('send', 'event', 'link', 'mailto', this.href);" href="mailto:service@xyz?subject=Demo%20Request">mailto: link</a>.
If you’re using jQuery, you can similarly use the .mousedown() listener instead of .click().
Whichever option you choose to capture your events, you can test your events in the Real-Time reports.