Track Users with there Basic Auth Username

Problem:
I have a Site where i have to track Users with there Username given in a Apache Login Form,
generated from a .htaccess/htpasswd combination.

I have a PHP driven Application so i used this way to solve my Problem:

Solution:
fill a Variable with the Infos from the Login Credentials:


<?php  
$loginuser = $_SERVER['REMOTE_USER'] ;
?>

Use this Data in a Custom Variable of the Tracking Code:


var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 2);
var userName = "<?php echo $loginuser; ?>";
piwikTracker.setCustomVariable(1, "Username", userName, scope = "visit");
piwikTracker.trackPageView();

Regards Oliver