Preference for certain settings: HTTP API or PHP API / fopen or cURL

These are settings found in certain modules, like the WP-Matomo module, and I am wondering if there is any preference if both types are supported by the setup.

Connect to Matomo >> Matomo Mode:

Self-hosted (PHP API) or Self-hosted (PHP API)

You can choose between three connection methods:
Self-hosted (HTTP API, default): This is the default option for a self-hosted Matomo and should work for most configurations. WP-Matomo will connect to Matomo using http(s).
Self-hosted (PHP API): Choose this, if your self-hosted Matomo and WordPress are running on the same machine and you know the full server path to your Matomo instance.

I have both running on the same machine, so I have selected Self-hosted (PHP API) and provided the file path to my Matomo instance.

Expert Settings >> HTTP connection via:

cURL or fopen

Choose whether WP-Matomo should use cURL or fopen to connect to Matomo in HTTP or Cloud mode.

I have selected cURL because I have read here that in a speed comparison it was 4 times faster.

Any more information or opinions on these settings, especially concerning security and performance?


@WP_PiwikDev can probably tell more about this, but my opinion is the following.

I’d go with Self-hosted (HTTP API) as this is the most used API and therefore it is less likely to have obscure bugs in it simply by having far more people using it.

Regarding cURL or fopen: You can’t go wrong with either of them. As long as the HTTP request to Matomo works, it is fine.
Even if cURL was faster, it wouldn’t matter much as it is not used for Tracking (if you are using the normal tracking code), but just for API requests for e.g. showing the reports in Wordpress or fetching the tracking code.

1 Like

@Lukas, I have now reverted back to Self-hosted (HTTP API, default) and HTTP connection via fopen because of your advice and because the proxy script strangely does not work with cURL (though the README file from the matomo-org / tracker-proxy Github repo shows allow_url_fopen=On as a requirement).