Matomo not tracking any data through API

Hello.
I have such a problem, I want to get statistics from my sites and I use Matomo for this.
I use Matomo v 3.11.0
With Matomo we can get statistics in 2 ways, one through installing JavaScript tracking-code on every page of the website and the second through API. The first method works for all my sites, but it does not suit me, so I need to use the second.
I have sites on different servers, some use a web server on Apache + Nginx, others Nginx + PHP-FPM.
From sites on web server with Apache + Nginx I recieve statistics using one of two methods JavaScript tracking-code or API.
But for sites which use only Nginx as web server(Nginx + PHP-FPM) Matomo not tracking any data through the second method(API).

Hi,

Can you explain how exactly you are using the API? Are you using one of the official libraries/SDKs? Do you send your own HTTP requests?

You could try enabling Tracking HTTP API: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3 to see why the API request is not saved in Matomo.

Thank you for reply and your advice.
I’ve found the problem, it was my fault.
By mistake I defined constant MATOMO_PROXY_FROM_ENDPOINT twice.
I enabled debugging and have found in console log following notice:
Notice: Constant MATOMO_PROXY_FROM_ENDPOINT already defined in /data/www/site.com/proxy.php on line 3
The notice error was in widget.php

widget.php code:
define(‘MATOMO_PROXY_FROM_ENDPOINT’, 1);

$path = “piwik.php”;

include dirname(FILE) . ‘/proxy.php’;

proxy.php code was taken from here https://raw.githubusercontent.com/matomo-org/tracker-proxy/master/proxy.php with some customizations.

So in proxy.php and widget.php was defined the same constant MATOMO_PROXY_FROM_ENDPOINT.
I commented in widget.php this line of code:
define(‘MATOMO_PROXY_FROM_ENDPOINT’, 1);
and now it works fine.
Thank you very much.

1 Like