matomo-org / tracker-proxy

HTTP proxy for Matomo's tracker API. This script allows to track websites with Matomo without revealing to your visitors the secret Matomo server URL.
http://matomo.org/faq/how-to/faq_132/
GNU General Public License v3.0
152 stars 46 forks source link

no tracking - installed the proxy script as described #45

Closed meentix closed 6 years ago

meentix commented 6 years ago

Hi,

Ive updated the old piwik.php and replaced it with the current version. So Ive downloaded and uploaded piwik.php, proxy.php, matomo-proxy.php & plugins/HeatmapSessionRecording/configs.php to my webspace, you can access them at http://www.psyheu.de/piwik.php, http://www.psyheu.de/proxy.php, http://www.psyheu.de/matomo-proxy.php & http://www.psyheu.de/plugins/HeatmapSessionRecording/configs.php - Ive also set $PIWIK_URL and $TOKEN_AUTH in the proxy.php and changed the js-snippet as you can see in source code of http://www.psyheu.de - but there is no working tracking any longer, I dont know why. It worked with the old piwik proxy script but now its not :-( How can I find out the problem?

meentix commented 6 years ago

Nobody has an idea? :-(

level420 commented 6 years ago

@meentix did you also check the config.php file and the TOKEN_AUTH therein?

meentix commented 6 years ago

Which config.php? Ive used the manual installation by downloading the four mentioned files and setting the correct $PIWIK_URL and $TOKEN_AUTH in the proxy.php. Ive done this with two other projects the same (that means without a config.php too) and the tracking is working there :-/

level420 commented 6 years ago

Ah OK then you've modified proxy.php. I prefer using the config.php file as it allows me to leave proxy.php unchanged.

Do you see any access to the matomo instance (access log of the http-server where the matomo instance is living on) when visiting a page at http://www.psyheu.de ?

level420 commented 6 years ago

Also on http://www.psyheu.de/datenschutz/ in the matomo section there is not the opt iframe/checkbox visible, but a login window. I think this is not intended?!?!?

meentix commented 6 years ago

Yes, Ive modified proxy.php.

Yeah I see access and an error, here is one example:

2018-05-28 16:31:38 Error xxx 400 GET /piwik.php?cip=xxx&token_auth=xxx&action_name=www.psyheu.de%2FUngew%C3%B6hnliche+Sex-Praktiken&idsite=4&rec=1&r=409968&h=16&m=31&s=38&url=http%3A%2F%2Fwww.psyheu.de%2F6744%2Fsexuelle-praktiken-perversion-paraphilie%2F&urlref=android-app%3A%2F%2Fcom.google.android.googlequicksearchbox&_id=b0ad0a49fff7fee2&_idts=1527517899&_idvc=1&_idn=0&_refts=1527517899&_viewts=1527517899&_ref=android-app%3A%2F%2Fcom.google.android.googlequicksearchbox&send_image=1&cookie=1&res=360x640&gt_ms=347&pv_id=vkVIu8 HTTP/1.0     3.85 K SSL/TLS-Zugriff für Apache
2018-05-28 16:31:38 Error xxx   AH01071: Got error 'PHP message: Error in Matomo (tracker): Invalid idSite: '0'\n'       Apache-Fehler

Ive removed the token_auth and ip address from the link in the logfile (xxx), but they are correct set there . There seems to be a problem with the siteId, but its set in the js code in the tracked site and it is in the refferer url :-/

The problem in the datenschutz-section is also not intended, right.

level420 commented 6 years ago

@meentix sorry no idea what's wrong. I've compared the GET request you've added with the GET requests on my sites and I can't find a difference regarding the idsite parameter.

You could maybe test if matomo is tracking correctly without the proxy if your matomo instance is reachable from outside. If this works it is clearly the fault of the proxy, if not you should check your matomo installation.

meentix commented 6 years ago

The tracking without proxy is working correctly and with the old proxy script everything worked fine before but not with the new one. That means there must be a problem with the new proxy script :-(

level420 commented 6 years ago

Did you compare the two GET requests? I mean the GET request which is caused against the matomo instance via the proxy and the GET request which is caused against the instance by using the non-proxied method.

And which matomo version are you using? Is it matomo 3.5 (latest is 3.5.1)?

meentix commented 6 years ago

They are different of course, but I think that relates to the non-use of the proxy script now:

GET /piwik.php?action_name=www.psyheu.de%2FWahre%20Liebe%3A%20Woran%20erkennt%20man%20sie&idsite=4&rec=1&r=964452&h=11&m=17&s=51&url=http%3A%2F%2Fwww.psyheu.de%2F10315%2Fwahre-liebe-woran-erkennt-man-sie%2F&urlref=https%3A%2F%2Fwww.google.de%2F&_id=8aef1ff58f3c0ef7&_idts=1527671871&_idvc=1&_idn=0&_refts=1527671871&_viewts=1527671871&_ref=https%3A%2F%2Fwww.google.de%2F&send_image=1&cookie=1&res=375x667&gt_ms=364&pv_id=7vv2K4 HTTP/1.1

I also track other sites with the new proxy script and this matomo instance where the tracking works :-/ One exemple:

GET /piwik.php?cip=xxx&token_auth=xxx&action_name=www.unfallrente.net%2FRente+der+Berufsgenossenschaft+%28BG+Rente%29&idsite=3&rec=1&r=278433&h=11&m=20&s=42&url=https%3A%2F%2Fwww.unfallrente.net%2Fgesetzliche-unfallversicherung%2Fberufsgenossenschaft-bg&urlref=https%3A%2F%2Fwww.google.de%2F&_id=6aae842819ea66df&_idts=1527672043&_idvc=1&_idn=0&_refts=1527672043&_viewts=1527672043&_ref=https%3A%2F%2Fwww.google.de%2F&send_image=1&cookie=1&res=360x640&gt_ms=249&pv_id=QGq3Mr HTTP/1.0

Im using the latest one 3.5.1, but Ive also tried it with 3.5 before.

level420 commented 6 years ago

@meentix sorry, but I'm giving up. No more ideas :-(

diosmosis commented 6 years ago

Hi @meentix can you try the following:

?

meentix commented 6 years ago

Hi @diosmosis

Ive set the $PIWIK_URL in the proxy.php; where I should set the $PROXY_URL? Ive used the manual installation of the proxy (no use of git or so).

Ive set the $DEBUG_PROXY to true in proxy.php and I dont see any PHP errors, do you see some? I only see the error in the serverlogs:

"2018-06-05 15:42:44 | Error | xxx |   | AH01071: Got error 'PHP message: Error in Matomo (tracker): Invalid idSite: '0'\n' |   |   |   | Apache-Fehler -- | -- | -- | -- | -- | -- | -- | -- | --"

diosmosis commented 6 years ago

@meentix $PROXY_URL should be set in the same place $PIWIK_URL is set. Eg:

$PIWIK_URL = ...;
$PROXY_URL = 'http://www.psyheu.de/';

If you set $PIWIK_URL in proxy.php, then you can set $PROXY_URL on the next line.

If your PHP isn't configured to print errors you wouldn't see it in the output. You could try adding (again temporarily) error_reporting(E_ALL); ini_set("display_errors", 1); to the beginning of proxy.php, but depending on how your PHP is configured, it may not work. If neither of these resolve your issue, we can try debugging more.

meentix commented 6 years ago

Ive updated the php version from 7.0 to 7.1 yesterday and after it the tracking with proxy works, so I think there was maybe a problem with this special php version (7.0)?

diosmosis commented 6 years ago

Glad to hear your issue is resolved! Closing this issue now, feel free to reply or create another issue if you run into another problem.

Re PHP 7.0, tested locally w/ PHP 7.0.35, works for me, let me know if you find a specific issue w/ 7.0 (if you care to look, no worries if not).