Server-Side Tracking Fails when setTokenAuth is set

I am trying to implement server side tracking and can successfully see page views within Matomo, however, each visitor is showing the servers IP address.

After reading the docs, and to get around this, I am settings setTokenAuth, but I then lose all tracking. As soon as I comment out the setTokenAuth line, it all starts again.

Where could I be going wrong?

      $matomoTracker = new MatomoTracker($matomoSiteId, $matomoUrl );
      if (is_user_logged_in()) {
      $matomoTracker->doTrackPageView( $page_title );

(The variables all return the correct values)

1 Like

I have been doing some further testing and the setUserId is working correctly (but again without the setTokenAuth which shows the code is working but not when elevation is needed.

Any ideas?


Hi @nbwpuk
What are the rights associated to the tocken? Maybe the minimum right should be probably tracked site admin…


That was a good thought, but to make sure I have created it against a superadmin so should have full permissions.

1 Like