You can’t really use localhost unless you are running both your server and browser on the same machine which will then break PHP.
The easiest way I’ve found is to modify your local hosts file to create a testbed. for example you could create a hostname of www.mypiwiktesting.com and point it to 127.0.0.1.
thanks for your answer, so if I get it right, I need to go to my domain name provider, buy a domain name such as www.mypiwiktest.com and modify the DNS in order for it to point to 127.0.0.1, am I right?
As I said, just for testing you can create your own domain and put it into your computers hosts file. Your computer will look at that first before it goes out to a DNS server to look it up. Take a look at http://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/ for details. This is for Windows but can be used for any other computer as well (The location of the hosts file will be different).
first of all, thanks I succeeded in creating www.mypiwiktesting.com (I did not know we could do that locally
I tried again to track one of my page with the following code (but nothing is happening, any ideas?) :
<?php
// -- Piwik Tracking API init --
require_once "PiwikTracker.php";
PiwikTracker::$URL = 'http://www.mypiwiktesting.com/piwik/';
?>
<?php
echo '<img src="'. str_replace("&","&", Piwik_getUrlTrackPageView( $idSite = 1, $customTitle = 'This title will appear in the report Actions > Page titles')) . '" alt="" />'
?>
Thanks Valdhor once more for your help. Well I am currently writing a book about Piwik and I would like to test all his functionalities by providing tutorials to the users. I am testing all functionalitites before showing them to the readers. That’s why I wanted to test it by myself first.
I am going to insert the code on a real server in order to see if it works or not.