Tracking but thinks everyone is me

Ok, here is the situation. And yes I read the forums, and searched them, and read the docs.

I am only using the trackingAPI via php. I refuse to use JavaScript on my site.

Anyway,Piwik is tracking just fine. But… all my visitors are being listed as having my webhosts IP address, and their provider being my web hosting provider. And yes, I can easily get visitor IP from other scripts on my site, so my web host isn’t sending the wrong IP information. Piwik does seem to be differentiating between browsers and OSs just fine, and even some countries (I think it’s doing that via language). So Piwik is tracking, it just isn’t pulling the correct IP address, which is an incredibly important aspect for me.

Normally this would be easily fixable, because you do have a way to force an IP address; the setIp method, but sadly that is “allowed only for Super User, must be used along with setTokenAuth()” which, frankly makes no sense what-so-ever. In an ideal world, I’d just pass along the proper IP via this method… but… well it’s restricted.

Here is a copy of my tracking code. For security reasons the tracker is renamed, along with the piwik directory. Again, these are not issues because piwik is tracking, just not correctly. The $PageTitle and $PageUrl variables are obvious and also tracking perfectly.

// – Piwik Tracking API init –
require_once “pt.php”;
PiwikTracker::$URL = ‘’;
$t = new PiwikTracker( $idSite = 1, ‘’);
// Optional function calls
//$t->setPlugins($flash = true, $java = true, $director = false);
// set a Custom Variable called ‘Gender’
//$t->setCustomVariable( 1, ‘gender’, ‘male’ );
// Mandatory: set the URL being tracked
$t->setUrl( $url = $PageUrl );
// Finally, track the page view with a Custom Page Title
// In the standard JS API, the content of the tag would be set as the page title

Now, just to make sure you know I did troubleshoot this, I’m going to answer some of your troubleshooting advice from your website. Hopefully this all is enough data for you to work with.

“1) Incorrect Piwik tracking code. Please check that you can find the Piwik javascript code on your website pages that you wish to track.”

I’m not using the JavaScript code.

“2) Make sure you are viewing reports for the correct website and date in Piwik”

Yes I Am

“3) Please wait at least 10 seconds after generating visits on your website: by default Piwik will only process reports every 10 seconds when “today” is selected.”

Does Not Relate to my problem as the reports are there, they are just showing the wrong IP address.

  1. “If your Piwik tracking code is properly installed, Piwik would record visits in your database. You can use phpMyAdmin to look at the table “piwik_log_visit” and see if there are visits recorded.”

Oh, all sorts of rows. All showing my webhosts IP address and my webhost name as provider.

“5) Testing Piwik with disabled Javascript. By default, Piwik only tracks visitors with javascript enabled. When you are testing that Piwik tracks visits properly make sure you have javascript enabled.”

I’m not using JavaScript.

“6) If you need to use a tracking method which doesn’t involve javascript have a look at docs/tracking-api.”

Gone through it backwards and forwards.

“7) Access to piwik.php fails”

Not an issue.

“8) Tracking https (SSL) pages”

Not an issue.

“9) Local copy of piwik.js outdated”

Downloaded latest version today… and I’m not using JavaScript anyway.

Yes, you must use setIp() to force the IP. Since 1.4RC (see other post) you can pass any “admin” token_auth (or the super user token_auth) so it should make it easier for you.

Ok, good news. Working great now. I understand where a token situation might be desirable and more secure. But I think in many situations it might not be required. But I am sure there must be a very solid reason for why this is required, so I won’t harp on it anymore. Thanks for the help.

As for anyone who might want to get IP addresses to pass along to Piwik, here is a pretty decent function I use. Simply put “$t->setIp( getRealIpAddr() );” (modify as needed) with your other Piwik code. Make sure you set the token too. And also add this function to your code or to a file that is included with all your scripts.

function getRealIpAddr()
if (!empty($_SERVER[‘HTTP_CLIENT_IP’])) //check ip from share internet
elseif (!empty($_SERVER[‘HTTP_X_FORWARDED_FOR’])) //to check ip is pass from proxy
return $rip;