Matomo Tracking Script is failing as the api throws Bad Request

I am currently experiencing issues with the Matomo tracking script on my website. Despite implementing the script as per the instructions on your website, it does not seem to be working correctly. I checked the API call in the network tab and found that it failed due to bad requests. I have added the details below.

Error is seen in the browser console:

The method ‘setTrackingSource’ was not found in “_paq” variable. Please have a look at the Matomo tracker documentation: https://developer.matomo.org/api-reference/tracking-javascript

TypeError: The method ‘setTrackingSource’ was not found in “_paq” variable. Please have a look at the Matomo tracker documentation: https://developer.matomo.org/api-reference/tracking-javascript

API Failure recorded in network tab:

POST https://analytics.fctly.de/matomo.php?action_name=Combifam%20%E2%80%93%20Official%20Site%20of%20Combifam%20FC%E2%80%A6&idsite=8&rec=1&r=011262&h=14&m=52&s=23&url=https%3A%2F%2Fcombifam.com%2F&_id=107a9b209baf44db&_idn=0&send_image=0&_refts=0&pdf=1&qt=0&realp=0&wma=0&fla=0&java=0&ag=0&cookie=1&res=1366x768&pv_id=Y1GDiY&pf_net=719&pf_srv=1393&pf_tfr=3&uadata=%7B%22fullVersionList%22%3A%5B%7B%22brand%22%3A%22Chromium%22%2C%22version%22%3A%22112.0.5615.139%22%7D%2C%7B%22brand%22%3A%22Google%20Chrome%22%2C%22version%22%3A%22112.0.5615.139%22%7D%2C%7B%22brand%22%3A%22Not%3AA-Brand%22%2C%22version%22%3A%2299.0.0.0%22%7D%5D%2C%22mobile%22%3Afalse%2C%22model%22%3A%22%22%2C%22platform%22%3A%22Windows%22%2C%22platformVersion%22%3A%2210.0.0%22%7D 400 (Bad Request)

Query String Parameters :

action_name: Combifam – Official Site of Combifam FC…
idsite: 8
rec: 1
r: 011262
h: 14
m: 52
s: 23
url: https://combifam.com/
_id: 107a9b209baf44db
_idn: 0
send_image: 0
_refts: 0
pdf: 1
qt: 0
realp: 0
wma: 0
fla: 0
java: 0
ag: 0
cookie: 1
res: 1366x768
pv_id: Y1GDiY
pf_net: 719
pf_srv: 1393
pf_tfr: 3
uadata: {"fullVersionList":[{"brand":"Chromium","version":"112.0.5615.139"},{"brand":"Google Chrome","version":"112.0.5615.139"},{"brand":"Not:A-Brand","version":"99.0.0.0"}],"mobile":false,"model":"","platform":"Windows","platformVersion":"10.0.0"}

Response from the API:

This resource is part of Matomo. Keep full control of your data with the leading free and open source web analytics & conversion optimisation platform.

This file is the endpoint for the Matomo tracking API. If you want to access the Matomo UI or use the Reporting API, please use index.php instead.

Tracking script used:

<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u=https://analytics.fctly.de/;
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '8']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>

<!-- End Matomo Code -->

Plugin used : WP-Matomo Integration (WP-Piwik) – WordPress plugin | WordPress.org

Note: This issue is not WordPress-specific. We are getting the same errors on other sites as well when we use the tracking script generated by our On-Premise Matomo Analytics.

Instance details:

Matomo version: 4.14.2
MySQL version: 5.7.42-0ubuntu0.18.04.1
PHP version: 8.2.4

We are stuck in our Matomo Analytics integration due to the above issues. How do I fix them?

2 Likes

Hi Satyam,
Are you still experiencing the issue?

We have just encountered the same problem with the selh-hosted Matomo (on premise), none Wordpress website.
The documentation does not provide answers regarding ‘setTrackingSource’.

Have you found a fix?

Hi @Lucien_Ledan, @Satyam_Suman
Isn’t a problem in the server request filter for example?
Some configurations forbid queries that could be interpreted as injection…