How to track custom event with data

Hi, I’m new to Matomo.

I want to use Matomo for all its classic analytics features but also for tracking custom events and add custom data to this events.
And I don’t think that this sort of tracking is possible with Matomo. I’ve seen the trackEvent or contentTracking but it seems to limited for my use case.

example of custom event I want to track : Track a click on a button to add an item to a wish list.
on this event I want to add data like the current user id doing the action, the item id, the current item category id, the type of page, a custom context, …
And the important part is that I want to retrieve the raw data of the event via the API. For now, displaying this event on matomo UI is not necessary.

Is this feature is natively feasible with Matomo, or via a Matomo plugin ?

If not, can you think it’s possible to develop a plugin to do it ?
and quite easily for a medium/good php developer ?

will it require a JS developer to integrate this new feature to a website or a code like this will succeed (if PHP part is develop) :

<a href="#" onclick="_paq.push(['trackMyDataEvent', {'action': 'wishlist', 'page': 'home', 'context': 'new', 'id': '123e4567-e89b-...', ...}]);">Add to wishlist page</a>

Thanks,
Julien.

Hi @jch
By default, if you track the page before the event, the event stays attached to the page (URL / title).
Then, you can also add custom dimensions to the tracked event:

https://developer.matomo.org/guides/tracking-javascript-guide#custom-dimensions

Please note that your event tracking code seems wrong. You should use:

<a href="mailto:name@example.com"
   title="Email Us"
   onclick="_paq.push(['trackEvent', 'Contact', 'Email Link Click', 'name@example.com']);"
   >Email Us</a>