Hello! My site uses Matomo tracking and generally visits are recorded by the JavaScript tracking code on each webpage. I recently wrote a php script that records a file download action for directly downloaded files (hosted on the website) whose links are included in emails we send out.
Essentially, this php script runs on our site and its main query parameter is the actual URL to the file download. The script records the download action using MatomoTracker.php and then 302 forwards the user to the file URL.
This script is working to record the download events in Matomo, but I notice that the same user is recorded with a separate visitor ID when they visit our site directly versus when the action tracking happens through the MatomoTracker.php script - it’s me testing, so I know I’m the same user on the same machine, IP, etc. I see the separate visitor IDs (and related actions) in the Matomo Dashboard.
Also, two separate _pk_id cookies are being recorded in the browser - I did notice that the one recorded by the JS site tag has a ‘.’ at the end, but maybe this makes no difference…
MatomoTracker.php:
_pk_id.1.3c4b:“2d39316d973a4504.1714754516”
Same user visiting site directly and recorded by JS tag on site:
_pk_id.1.d92f:“fea3c19f69775179.1714754519.”
I assume the MatomoTracker.php has access to the Request object, but I am setting the following explicitly when I create the tracker object:
$t = new MatomoTracker($idSite, $siteName);
$t->setUserAgent($_SERVER[‘HTTP_USER_AGENT’]);
$t->setLocalTime(date(‘H:i:s’));
$t->setBrowserHasCookies(isset($_COOKIE) && !empty($_COOKIE));
$t->setTokenAuth($token_auth);
$t->setIp(getRealIpAddr());
Is there any way to get all the events tracked under one Visitor ID?
Thank you!