How to track goals in Wordpress (WP-Piwik)

Seems like a basic question but haven’t yet found an answer: What’s the standard way to track Matomo goals in Wordpress?

I see the official docs reference the API, but without goal-specific examples, or an example script to use with the API request.

Do I need to write a short JS function to execute the AJAX call to the API? What does a goal-triggering REST API call look like (minimum required parameters)? Any docs on this specific topic? Thanks.

Hi,

It works the same way in Wordpress as it does on every other website:

https://developer.matomo.org/guides/tracking-javascript-guide#manually-trigger-goal-conversions

You can simply call _paq.push(['trackGoal', 1]); (with the ID of the goal) whenever you want to track the goal and the Matomo Javascript sends the right request to the API.

OK, that’s easy! I’ll try it.

Documentation like this confused me:

Matomo for WordPress doesn’t support our HTTP API but instead supports the WordPress REST API. View the reference and more information on our developer site. You can use it to automatically create goals, fetch reports, add annotations, and more. link

The regular Matomo HTTP Reporting API is not available within WordPress. Instead we utilise the WordPress REST API. link

Hi,

The Matomo reporting API (which allows you to view any report in Matomo in easily-usable format) has nothing to do with the Matomo Tracking API (which is the endpoint where tracking data is sent to).
And this again is separate from the Javascript functions one can use when using the normal matomo.js tracking client.
All three are explained on https://developer.matomo.org/api-reference