Javascript code does not works on a website

Hello,

For some reasons, one of the website I host doesn’t works with my second Matomo installation.

I have two websites, one being monitored by my first Matomo installation, which is working very fine since months.

Then a second website needed it, first I tried to link it to my original Matomo installation, but it was not working (same problem, see below) and since these project are completly unrelated, I decided to install another Matomo.

This second, as the first, is asking me to put this usual code:

<!-- Matomo -->
<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="//xxx.xxx.xx/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '1']);
    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 -->

Once it has been added to all .html pages, I click on the testing installation button, it open a new tab with the website I would like to monitore with Matomo, after a few seconds a new page is open and a red message says (in french) :


 La vérification du code de suivi a échoué. Veuillez vérifier que vous avez installé le code correctement.

(The code checking as failed (…).)

So I go, as asked, to this page but so far, to me, it’s fine.

The system is already doing it, from another Matomo installation with of course its own database, user, etc.

Incorrect Matomo tracking code

You can check it on any page on justine-muller.fr

Make sure you are viewing reports for the correct website and date in Matomo

There is only one for this Matomo installation.

Browser addons blocking the Matomo Tracking Javascript (NoScript, DoNotTrack, etc.)

I tried with no add-ons, also with Tor Browser with less security extension (such as NoScript) than my everyday browser.

Matomo by default supports [DoNotTrack]

I disabled it for this moment, not better.

Archiving triggered from the browser must be enabled, if it is disabled the Cron script must be configured properly

At first it was from browser, since I added the cron task, I get this as log:

INFO [2024-09-28 09:05:00] 1408609 ---------------------------
INFO [2024-09-28 09:05:00] 1408609 INIT
INFO [2024-09-28 09:05:00] 1408609 Running Matomo 5.1.2 as Super User
INFO [2024-09-28 09:05:00] 1408609 ---------------------------
INFO [2024-09-28 09:05:00] 1408609 NOTES
INFO [2024-09-28 09:05:00] 1408609 - Async process archiving supported, using CliMulti.
INFO [2024-09-28 09:05:00] 1408609 - Reports for today will be processed at most every 900 seconds. You can change this value in Matomo UI > Settings > General Settings.
INFO [2024-09-28 09:05:00] 1408609 - Archiving was last executed without error 59 min 59s ago.
INFO [2024-09-28 09:05:01] 1408609 ---------------------------
INFO [2024-09-28 09:05:01] 1408609 START
INFO [2024-09-28 09:05:01] 1408609 Starting Matomo reports archiving…
INFO [2024-09-28 09:05:01] 1408609 0 out of 3 archivers running currently
INFO [2024-09-28 09:05:01] 1408609 Start processing archives for site 1.
INFO [2024-09-28 09:05:01] 1408609 Finished archiving for site 1, 0 API requests, Time elapsed: 0.021s [1 / 1 done]
INFO [2024-09-28 09:05:01] 1408609 Done archiving!
INFO [2024-09-28 09:05:01] 1408609 ---------------------------
INFO [2024-09-28 09:05:01] 1408609 SUMMARY
INFO [2024-09-28 09:05:01] 1408609 Processed 0 archives.
INFO [2024-09-28 09:05:01] 1408609 Total API requests: 0
INFO [2024-09-28 09:05:01] 1408609 done: 0 req, 154 ms, no error
INFO [2024-09-28 09:05:01] 1408609 Time elapsed: 0.154s
INFO [2024-09-28 09:05:01] 1408609 ---------------------------
INFO [2024-09-28 09:05:01] 1408609 SCHEDULED TASKS
INFO [2024-09-28 09:05:01] 1408609 Starting Scheduled tasks…
INFO [2024-09-28 09:05:01] 1408609 Scheduler: executing task Piwik\Plugins\CustomJsTracker\Tasks.updateTracker…
INFO [2024-09-28 09:05:01] 1408609 Scheduler: finished. Time elapsed: 0.020s
INFO [2024-09-28 09:05:01] 1408609 Scheduler: executing task Piwik\Plugins\PrivacyManager\Tasks.deleteLogData…
INFO [2024-09-28 09:05:01] 1408609 Scheduler: finished. Time elapsed: 0.000s
INFO [2024-09-28 09:05:01] 1408609 Scheduler: executing task Piwik\Plugins\PrivacyManager\Tasks.anonymizePastData…
INFO [2024-09-28 09:05:01] 1408609 Scheduler: finished. Time elapsed: 0.003s
INFO [2024-09-28 09:05:01] 1408609 done
INFO [2024-09-28 09:05:01] 1408609 ---------------------------

Third party Matomo plugins

None, vanilla.

Do you have logs registered in your Matomo database?

It’s not working, how could it logs anything ?

Testing Matomo with disabled Javascript

Tested without Javascript AND with Javascript enabled.

Matomo displays a red cross (on IE) or a broken image icon on your tracked pages, instead of the 1*1 transparent Pixel

Tested on Firefox / Tor Browser, last version.

Access to piwik.php fails

Not sure to understand this part, but so far I don’t feel concerned ?

Tracking https (SSL) pages

SSL is forced from the config.php, my browser redirected always to HTTPS and my virtual host is forcing redirection to HTTPS.

Local copy of piwik.js outdated

Full fresh install with lastest version took on the download page of Matomo.

Using Matomo latest version

It’s my case, actually it’s 5.1.2 and Matomo confirm it.

Check your webserver error logs

The logs I get when trying to test the installation of the js code. From access, nothing reported from error.log.

192.168.1.254 - - [28/Sep/2024:11:39:16 +0200] “GET /index.php HTTP/2.0” 302 0 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:16 +0200] “GET /index.php?module=CoreHome&action=index&idSite=1&period=day&date=yesterday HTTP/2.0” 200 60846 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:16 +0200] “GET /index.php?module=Proxy&action=getNonCoreJs&cb=a4e84b8908f5c1acb6a7750503923f20 HTTP/2.0” 499 0 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:16 +0200] “POST /index.php?date=yesterday&module=API&format=json&method=API.getPagesComparisonsDisabledFor&segment=&idSite=1&period=day HTTP/2.0” 200 230 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101
Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:16 +0200] “GET /plugins/CoreHome/images/applogo_256.png HTTP/2.0” 200 10278 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:16 +0200] “GET /plugins/CoreHome/images/applogo_256.png HTTP/2.0” 200 10278 " “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:16 +0200] “POST /index.php?date=yesterday&module=SitesManager&format=json&action=getTrackingMethodsForSite&segment=&idSite=1&period=day HTTP/2.0” 200 26995 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/201001
01 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:16 +0200] “GET /plugins/SitesManager/images/code.svg HTTP/2.0” 200 391 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:16 +0200] “GET /plugins/SitesManager/images/mtm.png HTTP/2.0” 200 59027 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:16 +0200] “GET /plugins/SitesManager/images/gtm.svg HTTP/2.0” 200 805 " “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:16 +0200] “GET /plugins/SitesManager/images/wordpress.svg HTTP/2.0” 200 1783 " “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:16 +0200] “GET /plugins/SitesManager/images/vuejs.svg HTTP/2.0” 200 540 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:16 +0200] “POST /index.php?date=today&module=API&format=json&method=Live.getMostRecentVisitsDateTime&period=day&idSite=1&segment= HTTP/2.0” 200 12 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefo
x/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:18 +0200] “POST /index.php?date=today&module=API&format=json&method=Live.getMostRecentVisitsDateTime&period=day&idSite=1&segment= HTTP/2.0” 200 12 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefo
x/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:19 +0200] “POST /index.php?date=yesterday&module=API&format=json&method=SitesManager.getExcludedQueryParameters&idSite=1&filter_limit=-1&segment=&period=day HTTP/2.0” 200 2 “” “Mozilla/5.0 (X11; Linux x86_64; rv:13
0.0) Gecko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:19 +0200] “POST /index.php?date=yesterday&module=API&format=json&method=SitesManager.getExcludedReferrers&idSite=1&filter_limit=-1&segment=&period=day HTTP/2.0” 200 2 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) G
ecko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:19 +0200] “POST /index.php?date=yesterday&module=API&format=json&method=SitesManager.getSiteUrlsFromId&idSite=1&filter_limit=-1&segment=&period=day HTTP/2.0” 200 31 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gec
ko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:19 +0200] “POST /index.php?date=yesterday&module=API&format=json&method=JsTrackerInstallCheck.wasJsTrackerInstallTestSuccessful&segment=&period=day HTTP/2.0” 200 59 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gec
ko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:19 +0200] “POST /index.php?date=yesterday&module=API&format=json&method=SitesManager.getJavascriptTag&idSite=1&segment=&period=day HTTP/2.0” 200 618 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Fire
fox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:20 +0200] “POST /index.php?date=today&module=API&format=json&method=Live.getMostRecentVisitsDateTime&period=day&idSite=1&segment= HTTP/2.0” 200 12 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefo
x/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:21 +0200] “POST /index.php?date=yesterday&module=API&format=json&method=JsTrackerInstallCheck.initiateJsTrackerInstallTest&segment=&period=day HTTP/2.0” 200 135 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/2
0100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:22 +0200] “POST /index.php?date=yesterday&module=API&format=json&method=JsTrackerInstallCheck.wasJsTrackerInstallTestSuccessful&segment=&period=day HTTP/2.0” 200 59 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gec
ko/20100101 Firefox/130.0”

192.168.1.254 - - [28/Sep/2024:11:39:23 +0200] “POST /index.php?date=today&module=API&format=json&method=Live.getMostRecentVisitsDateTime&period=day&idSite=1&segment= HTTP/2.0” 200 12 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefo
x/130.0”

192.168.1.254 - - [28/Sep/2024:11:39:24 +0200] “POST /index.php?date=yesterday&module=API&format=json&method=JsTrackerInstallCheck.wasJsTrackerInstallTestSuccessful&segment=&period=day HTTP/2.0” 200 59 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gec
ko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:27 +0200] “POST /index.php?date=yesterday&module=API&format=json&method=JsTrackerInstallCheck.wasJsTrackerInstallTestSuccessful&segment=&period=day HTTP/2.0” 200 59 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gec
ko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:28 +0200] “POST /index.php?date=today&module=API&format=json&method=Live.getMostRecentVisitsDateTime&period=day&idSite=1&segment= HTTP/2.0” 200 12 “” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefo
x/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:30 +0200] “POST /index.php?date=yesterday&module=API&format=json&method=JsTrackerInstallCheck.wasJsTrackerInstallTestSuccessful&segment=&period=day HTTP/2.0” 200 59 “/” “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gec
ko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:32 +0200] “POST /index.php?date=yesterday&module=API&format=json&method=JsTrackerInstallCheck.wasJsTrackerInstallTestSuccessful&segment=&period=day HTTP/2.0” 200 59 “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gec
ko/20100101 Firefox/130.0”
192.168.1.254 - - [28/Sep/2024:11:39:35 +0200] “POST /index.php?date=today&module=API&format=json&method=Live.getMostRecentVisitsDateTime&period=day&idSite=1&segment= HTTP/2.0” 200 12 “Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefo
x/130.0”

Troubleshooting when a tracking request is sent correctly but data is not visible in ‘Visits log’

Can’t see matomo.php. I see this on the matomo testing page:

/index.php?module=Proxy&action=getCoreJs&cb=a4e84b8908f5c1acb6a7750503923f20
/index.php?module=Proxy&action=getNonCoreJs&cb=a4e84b8908f5c1acb6a7750503923f20
/index.php?module=Proxy&action=getUmdJs&chunk=0&cb=a4e84b8908f5c1acb6a7750503923f20
/index.php?module=Proxy&action=getUmdJs&chunk=1&cb=a4e84b8908f5c1acb6a7750503923f20
/index.php?module=Proxy&action=getUmdJs&chunk=2&cb=a4e84b8908f5c1acb6a7750503923f20

Get, all are returning code 200, on the actual site I try to monitor, I only got hello.js.


On a side note, the sanity checker of Matomo reports NO problem.


I might not properly executed some of these tests, or missed something more important while installing, I do not know.

Any ideas on how to solve this ? I had really an easy installation for the first web site, but this one is so painfuly not working.

Regards,
GASPARD DE RENEFORT Kévin

Is there an appropriate trusted_hosts[] = entry in config.ini.php for this install?

I have noticed that in your POST from justine-muller back to stats.justine-muller the urlref parameter is missing.

1 Like

You may find the following helpful:

1 Like

Hello,

Thanks for your answer.

1/ After adding

trusted_hosts = “thewebsite [dot] tld”

It seemed to works.

2/ But, it works since… Friday ! Just noticed that… Somehow now it’s displaying. But if I remove this line, it works too.

There was also already a line with trusted_host for the actual matomo’s URL.

Should I keep the trusted_hosts = on the target website, keeping the other line too ?

Regards,
GASPARD DE RENEFORT Kévin

I don’t know for sure, but I suspect that the config.ini.php is only read when the php server is (re)started, so any changes made to it while it’s running may not take effect.
As for keeping the other trusted_hosts line, unless it’s a security risk, no reason to remove it. Sorry, I am very new to Matomo.