Comments (9)
@NicoHood this works for me nicely. It sets the correct parameter send_image=0
and returns HTTP 204. Can you maybe check again in the developer tools for example?
You can track the resolution using the setResolution($width, $height)
method.
from matomo-php-tracker.
I also tried it again and it works now. I am not sure what I did wrong, I assume it was my mistake. Really strange. Sorry for the confusion.
However the response code is always 400 (bad request) and in the dashboard I cannot see any page view.
$matomoTracker = new MatomoTracker((int)$site_id, $matomo_url);
$matomoTracker->setTokenAuth($token);
dump($matomoTracker->getUrlTrackPageView($page->title()));
// -> I then manually enter the url in the browser
from matomo-php-tracker.
You can try enabling the debug mode of the Tracker in Matomo by adding this to your config.ini.php
[Tracker]
debug = 1
When you then open a tracking url in the browser you should see some debugging output. Maybe that helps to identify the problem.
from matomo-php-tracker.
Nice, the error is: Tracker API 'cip' was used, requires valid token_auth
.
Now I've set up a proper token, however the url returned by getUrlTrackPageView()
has no token set. If I remove the cip
option, it even works without a token.
By "working" I mean the correct response code is returned. The gif was sent anyways, even with a 400 response (I am not sure if that is intended)
Now I am am bit lost on how to fix that properly. This issue is related:
matomo-org/matomo#13854
#39
from matomo-php-tracker.
It turns out to be like that:
The reason why it does not work is, because I am setting an auth token. Because the auth token is specified the cip
parameter will be applied. However in the final request the token is missing, because sendRequest()
add the token, but when using getUrlTrackPageView()
(and others) this function is never called. doTrackPageView()
however works, as it also adds the token.
The workaround would be to:
- Do not set the token + use
getUrlTrackPageView()
- OR Set the token and use
doTrackPageView()
But why is the token omitted for getUrlTrackPageView()
requests? The token would be placed directly into the html. Is the token something sensible that should be hidden to the user?
Possible solutions:
- Only add
cip
insendRequest()
instead ofgetRequest()
- OR add the token also in the
getRequest()
instead of thesendRequest()
You should know best what to do.
from matomo-php-tracker.
Depending on the rights of the user the token belongs to, someone could do anything with your Matomo instance using the token, as it's also usable for authenticating any API request.
from matomo-php-tracker.
I also want to not that getUrlTrackPageView()
does not call generateNewPageviewId()
which means the "image" will be cached, as a random id for cache busting is missing. I guess that should be fixed as well?
from matomo-php-tracker.
You can likely get the &token_auth=
as part of the URL by calling $tracker->setRequestMethodNonBulk('GET')
. We would be usually posting the token for security reasons and not include it as a GET parameter by default so the token won't appear in the logs.
from matomo-php-tracker.
I also want to not that getUrlTrackPageView() does not call generateNewPageviewId() which means the "image" will be cached, as a random id for cache busting is missing. I guess that should be fixed as well?
The URL should always include a parameter r
that changes randomly.
from matomo-php-tracker.
Related Issues (20)
- Get current visitors channel and campaign params HOT 1
- More virtualization of MatomoTracker class HOT 6
- Uncaught RuntimeException when Matomo host DNS couldn't resolve HOT 5
- Goals attribution only show 'direct' attribution HOT 4
- PHP Deprecation warning when running tracker on PHP 8.1
- PHP 8.2: Creation of dynamic property NNN is deprecated HOT 3
- Generate a download in Behavior > Downloads HOT 2
- Drop support of older php versions? HOT 4
- new release HOT 1
- How to connect this with Matomo for Wordpress?
- Minor edit to documentation HOT 1
- Owner of this project? HOT 1
- How can I used this with cloudflare? HOT 3
- How to know if site ID or auth token are incorrect HOT 1
- Curl Connection remaining open.
- Creation of dynamic property MatomoTracker::$currentTs is deprecated HOT 5
- Notices HOT 1
- Speedup Curl-Request with various Parameters
- Licence Mismatch HOT 4
- No tracking since 1st of October HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from matomo-php-tracker.