How to track external link clicks?

I am using Yireo’s Joomla plugin that allows tracking for piwik through the http api.

https://www.yireo.com/software/joomla-extensions/piwik

I also want to track clicks on external links on my site. I saw an example (below) that said to add an onclick event to the url like so

<a href="some external link" onclick="javascript:_paq.push(['trackEvent', 'Menu', 'Freedom']);">Some text</a>

Will this work? It doesn’t seem to as I see nothing in the Piwik Outlinks report. Is the reason it doesn’t work is that I am using the http api solution instead of the javascript solution?

Is there a way to track external link clicks using the http api?

Thanks

Tom