matomo-org / cloudflare-app-manual

Matomo Analytics app for Cloudflare. Adds the tracking code when user already has a running Matomo
https://cloudflareapps.com/apps/piwik
Other
2 stars 4 forks source link

Matomo Cloudflare App won't work #3

Open amigthea opened 2 years ago

amigthea commented 2 years ago

How could I test the connection between cloudflare matomo app and matomo server? I setup all related settings but I can't get clients visits logged on matomo backend. I had the wordpress plugin and all was working but as soon as I switched to cloudflare app I can't get clients logs anymore

bx80 commented 2 years ago

Hi @Azertooth, thanks for contacting us.

I'd suggest first checking the Matomo installation settings that you provided to Cloudflare when setting up the Matomo App, specifically the url and site id. If your Matomo installation is in a subdirectory (eg. mydomain.com/matomo) then that would need to be included in the Cloudflare settings too.

To check that the tracking script is being correctly loaded by your Cloudflare site, you could view the site, open the browser web developer console, switch to the Network tab, reload and look for the connection that loads matomo.js to confirm that there are no errors.

For Cloudflare you should also have the following setting in config/config.ini.php to show real IP addresses.

[General]
proxy_client_headers[] = HTTP_CF_CONNECTING_IP

If that all works then it could be useful to check your Matomo web server access logs to confirm that incoming connections are being received and that there are no hosting rules blocking Cloudflare connections.

Hope that helps.

amigthea commented 2 years ago

Hi @bx80 and thank you for your time to reply

I already checked all of that before opening this issue, the only things I did't try is the config.ini settings, is that valid even if I do not have the proxy check enabled on cloudflare A record dns?

Findus23 commented 2 years ago

Hi,

Indeed, the proxy settings should be unrelated.

As you can see in https://github.com/matomo-org/cloudflare-app-manual/blob/master/source/app.js, this app is really simple and just executes the Matomo tracking code with the set settings. So can you check if this code is executed on your site (e.g. window._paq is set)?

amigthea commented 2 years ago

thank you @Findus23 for joining the discussion

I got my main website working integrating the tracking code directly on the webpages but I'm trying the cloudflare route with another website and that's still not working.

To check that the tracking script is being correctly loaded by your Cloudflare site, you could view the site, open the browser web developer console, switch to the Network tab, reload and look for the connection that loads matomo.js to confirm that there are no errors.

I'm stuck here, the matomo.js is not loaded on the client browser.

Where I could look out for troubleshooting the problem?

MichaIng commented 2 years ago

Generally it works, I tested it with Opera, Firefox, Edge and Brave. Of course in some cases the ad/tracker blocker blocks it, at least in Brave OOTB, hence an exception needs to be added.

You need to look into the browser console, the "sources" tab:

  1. Check whether the Cloudflare apps base scripts are loaded, a head and a body JavaScript.
  2. Check whether the body script contains the tracker call and settings you configured in the Cloudflare apps interface.
  3. Check whether the Matomo script is loaded.
  4. Check whether the browser console contains any error while trying to load any of those scripts or doing the final tracker request.