How to generate a report about the logged in USERs with the REMOTE_USER Variable


#1

I’ve searched in the internet and at the piwik.org site, but i don’t find any information about how to log the REMOTE_USER Variable in the piwik Dashboard.
For example in awstats i’am able to log the HTTP User which is logged in.

Could anyone help me how i could log this Variable inside the Piwik Dashboard ?

Thanks and regards,

Axel


(Matthieu Aubry) #2

You can set the value dynamically in the Javascript as a Custom Variable: Custom Variables Analytics - Analytics Platform - Matomo


#3

Hi Matt,

i have done a lot of searching in the last few days/weeks. But it is really difficult for me to setup a user defined variable within the javascript tracking.

Maybe you could give me one more hint how to read out the REMOTE_USER with Javascript?


(Matthieu Aubry) #4

something like


piwikTracker.setCustomVariable(1, 'user', '<? echo $_SERVER['REMOTE_USER']; ?>');
// before the line
piwikTracker.trackPageView();



#5

Thank you very much, Matt. And excuse please, that i’am currently not able to find out this by myself :wink:

Kind regards,

Axel


#6

Hi @All, Hi Matt,

now i’ve inserted the code into my piwik Plugin in the gallery3, and now the piwik installation don’t registrate new requests.
Here ist the Piwik-JS-Code


* You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
 */
class piwik_plugin_theme {
  static function page_bottom($theme) {
    $piwik_code = '
        <!-- Piwik -->
        <script type="text/javascript">
        var pkBaseURL = (("https:" == document.location.protocol) ? "https://'.module::get_var("piwik_plugin", "tracker" ).'" : "http://'.module::get_var("piwik_plugin", "tracker" ).'" );
        document.write(unescape("%3Cscript src=\'" + pkBaseURL + "piwik.js\' type=\'text/javascript\'%3E%3C/script%3E" ));
        </script><script type="text/javascript">
        try {
        var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", '.module::get_var("piwik_plugin", "site_id" ).');
        [b]piwikTracker.setCustomVariable(1, \'UserID\', \''.$_SERVER['REMOTE_USER'].'\', \'page\' );[/b]
        piwikTracker.trackPageView();
        piwikTracker.enableLinkTracking();
        } catch( err ) {}
        </script><noscript><p><img src="http://'.module::get_var("piwik_plugin", "tracker" ).'piwik.php?idsite='.module::get_var("piwik_plugin", "site_id" ).'" style="border:0" alt=""/></p></noscript>
        <!-- End Piwik Tag -->
';

    return $piwik_code;
  }
}

The generated Code inside the Page looks like this one:


<script type="text/javascript">var pkBaseURL = (("https:" == document.location.protocol) ? "https://piwik.2axels-company.de/" : "http://piwik.2axels-company.de/");
	document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
	</script><script type="text/javascript">try {
	var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
        [b]piwikTracker.setCustomVariable(1, 'UserID', 'blaufoto', 'page');[/b]
	piwikTracker.trackPageView();
	piwikTracker.enableLinkTracking();
	} catch( err ) {}
	</script><noscript><p><img src="http://piwik.2axels-company.de/piwik.php?idsite=1" style="border:0" alt=""/></p></noscript>

Now with this change there are no new request, that where logged inside the piwik-Admin Page.

Do you have any hints for me??

Thanks and regards

Axel


(Matthieu Aubry) #7

open the page with Firefox + Firebug extension and look at javaascript errors?


#8

[quote=matt]
open the page with Firefox + Firebug extension and look at javaascript errors?[/quote]
Hi Matt, i’am back again, with a new idea.

Under Linux, where i’am normally working, the piwik Code won’t be called. This is the source code from my browsers (ubuntu, 10.04 with a firefox 12.0) source code view:


<!--//--><script type="text/javascript">var pkBaseURL = (("https:" == document.location.protocol) ? "https://piwik.2axels-company.de/" : "http://piwik.2axels-company.de/");
	document.write(unescape("[b]%3C[/b]script src='" + pkBaseURL + "piwik.js' type='text/javascript'[b]%3E%3C/script%3E"));[/b]
	</script><script type="text/javascript">try {
	var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
	piwikTracker.setCustomVariable(1, 'UserID', 'blaufoto', 'visit'); 
	piwikTracker.trackPageView();
	piwikTracker.enableLinkTracking();
	} catch( err ) {}
	</script><noscript><p><img src="http://piwik.2axels-company.de/piwik.php?idsite=1" style="border:0" alt=""/></p></noscript> <!--//--></body></html>

I’am wondering about the “%3C” and “%3E%3C” sign inside the javacode.

By the way, on my XP-Virtual Machine with firefox 12 anything is working fine! But with Linux and FF12 nothing is being logged in Piwik.

This is the firebug source code view:


<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://piwik.2axels-company.de/" : "http://piwik.2axels-company.de/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript" src="http://piwik.2axels-company.de/piwik.js">
Seite neu laden, um den Quelltext zu holen für: http://piwik.2axels-company.de/piwik.js
</script>
<script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.setCustomVariable(1, 'UserID', 'blaufoto', 'visit');
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script>
<noscript><p><img src="http://piwik.2axels-company.de/piwik.php?idsite=1" style="border:0" alt=""/></p></noscript>
</body>
</html>

The Firebug under Linux shows only some warnings…


function g does not always return a value
http://piwik.2axels-company.de/piwik.js
Line 25

function J does not always return a value
http://piwik.2axels-company.de/piwik.js
Line 13

function a does not always return a value
http://piwik.2axels-company.de/piwik.js
Line 28

reference to undefined property x.GearsFactory
http://piwik.2axels-company.de/piwik.js
Line 25

Any idea? I’am looking a little bit helpless and don’t understand why this different behavior occurs.