MatomoTracker.php Question

I currently have Matomo set up since March 1 on premise. The server has has two domains. site1 = matomo platform and site2 = the domain being tracked. This is working well. I am now trying to get php server side tracking working. I added a website so that I can test this. When I go to the page that has the tracking code. I get a blank white page that loads and dies when it hits the $matomoTracker->doTrackPageView($matomoPageTitle);. If from my desktop I preview the page in PhpStorm it works and logs the pageview (from localhost). There is something I need to do, just not sure what.

My code:
$matomoSiteId = 10; // Site ID
$matomoUrl = “https://site1.org/matomo”; // Your matomo URL
$matomoToken = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”; // Your authentication token
$matomoPageTitle = “Test page”; // The title of the page
// Load object
require_once (“php/MatomoTracker.php”); // this is located on site2
// Matomo object
$matomoTracker = new MatomoTracker ($matomoSiteId, $matomoUrl);
// Set authentication token
$matomoTracker->setTokenAuth($matomoToken);
// Track page view
$matomoTracker->doTrackPageView($matomoPageTitle);

Ubuntu server 22.04
php 8.1.2
Apache 2.4.52

Perhaps this is a permissions issue or a matomo config. What has me stumped is that it works from within PhpStorm.

I need to be pointed in the right direction. Any help would be appreciated!

David

It looks like it’s a problem with curl. Ubuntu 22.04 is version 7.81.0. Version 7.87 fixes a host to host dns bug within same server. My desktop Gentoo version is 8.7.1. Must be why Phpstorm preview works.

I moved the Matomo directory to site2 and solved the problem.

1 Like