How do I fix the tracking failure « Request was not authenticated but should have. »
You see a failed tracking request with this error message when you use specific tracking parameters as part of the HTTP tracking API without authenticating the request correctly. Some parameters that require authentication are for example cip
(forcing a specific IP address), or cdt
(overrides the datetime of the request).
When such an error occurred, you need to make sure to set a token_auth of a user with at least write
permission. If you have set a token, check the set token to make sure it is still the same and no copy/paste error has happened.
Or if you are tracking a Mobile App using iOS or Android SDK, you may get this error when some requests are sent more than 1 day after they were generated on the device, and the custom datetime of the request is too far in the past and then they fail. That’s because by default, Matomo accepts only tracking requests for up to 1 day in the past. You can change how far back Matomo will track your requests without authentication. The configured value is in seconds. You can change this setting in config.ini.php by setting under [General] the following value for example 10 days (default is 1 day):
[Tracker]
tracking_requests_require_authentication_when_custom_timestamp_newer_than = 864000;
Note: You can also configure this setting on a per site basis.
You may also be interested in disabling the tracking failure emails.