How to make MatomoTracker igone IP?

Hello,

we are using generally the JS based Matomo tracking tag without issues, but we also want to use the PHP based MatomoTracker.php in some cases.

The problem is that the call from MatomoTracker is time-shiftet, and at this point we have the visitorId but not the client’s IP-address. We did some experiments and found that Matomo is using the IP-address of the process the CURL-call comes from when the IP is skipped. This results to always be 127.0.0.1, which makes Matomo group all calls from this to only one visitor (although the visitorId changes?!).

Is there a way to tell Matomo or the MatomoTracker to just use the IP-address that was last “connected” to the visitorsId?

Okay, it seems I were wrong: Matomo is doing it the right way, just taking the last IP address if it’s not given by MatomoTracker. It seems the problem occured because of an error on our side. We are still experimenting, but it looks good now.

To ensure Matomo uses the IP address last associated with the visitor ID, you need to explicitly set the IP address in the MatomoTracker.php call. Use the setIp() method to set the correct IP address for each tracking request. Here’s a brief example:

php

Copy code

$matomoTracker = new MatomoTracker($siteId, $matomoUrl);
$matomoTracker->setTokenAuth($tokenAuth);
$matomoTracker->setIp($clientIp); // Set the client's IP address
$matomoTracker->setVisitorId($visitorId);
// Add other tracking parameters here
$matomoTracker->doTrackPageView($pageTitle);

This ensures the correct IP address is associated with each tracking request.