Hello,
I am using Piwik to track an intranet site. What I would like to have is a report with user login, i.e.
domain_name\login_name, for example: RMC\a.smith, RMC\bill.anderson, etc
Thank you,
M.R.
Hello,
I am using Piwik to track an intranet site. What I would like to have is a report with user login, i.e.
domain_name\login_name, for example: RMC\a.smith, RMC\bill.anderson, etc
Thank you,
M.R.
Thanks Matt, I added the following code that stores the login name in custom variable1:
var userName = '<%=Request.ServerVariables("AUTH_USER")%>';
piwikTracker.setCustomVariable(1, "Login_name", userName, scope = "visit");
piwikTracker.trackPageView();
Regards,
M.R.
Looks good, just make sure you escape double quotes in case a username can contain double quotes!
OK, I’m trying to figure out how to make this work. I see the winky faces in M.R.'s code and assume those should be a semi-colon followed by a closing parenthesis - is that correct?
When I put that in as-is it breaks the page. So I changed it as follows, the two lines in red are what I added, is it right?:
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://myserver.com/piwik/" : "http://myserver.com/piwik/");
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);
var userName = Request.ServerVariables("AUTH_USER";);
piwikTracker.setCustomVariable(1, "Login_name", userName, scope = "visit";);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://myserver.com/piwik/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->
OK, still not working. I took the code and tried again, here is the code I put in the head of my master page:
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
var userName = '<%=Request.ServerVariables("AUTH_USER")%>';
piwikTracker.setCustomVariable(1, "Login_name", userName, scope = "visit");
piwikTracker.trackPageView();
And it broke, here is the error I get in the browser:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Runtime Error
Description: An application error occurred on the server.
Any idea what I can change to make it work?
Thanks in advance!
switch to non windows technology?
LOL - sorry, can’t. At home I use whatever I want, but here at the office I’m currently building my site in Sharepoint 2007 and soon, Sharepoint 2010. And all the users here are using IE of course.
Any ideas on how to pull the user login names in this environment?
Hello billcawly,
This is the entire code that I’m using:
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://10.3.7.19:9227/piwik/" : "http://10.3.7.19:9227/piwik/");
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);
var userName = '<%=right(Request.ServerVariables("AUTH_USER"), len(Request.ServerVariables("AUTH_USER")) - instr(Request.ServerVariables("AUTH_USER"), "\"))%>';
piwikTracker.setCustomVariable(1, "Login_name", userName, scope = "visit");
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch (err) { }
</script><noscript><p><img src="http://10.3.7.19:9227/piwik/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->
However… you may also need the following lines in your web.config file:
<authentication mode="Windows"/>
<identity impersonate="true"/>
Also, I have ‘Windows Authentication’ enabled in my IIS settings.
Regards,
M.R
I used your code but used SPServices Jquery from CodePlex.
Just make sure you include their script in head, then use:
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://10.3.7.19:9227/piwik/" : "http://10.3.7.19:9227/piwik/");
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);
var userName = $().SPServices.SPGetCurrentUser({ fieldName: "Name", debug: false });
piwikTracker.setCustomVariable(1, "Login_name", userName, scope = "visit");
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch (err) { }
</script><noscript><p><img src="http://10.3.7.19:9227/piwik/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->
Dear all,
I tried to track my users by the custom variables with this code :
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + “piwik.php”, 1);
var userName = ‘<%=Request.ServerVariables(“AUTH_USER”)%>’;
piwikTracker.setCustomVariable(1, “Login_name”, userName, scope = “visit”);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
As a result, I have “Login_name: <=Request.ServerVariables(“AuthUser”)>” which appears in the visitor log.
Do you have a solution regarding this issue?
Thank you in advance, best regards.
What software do youuse? the code depends on your website, CMS, etc.
My website is hosted by Infomaniak.
I added the code in the ‘piwik’ javascript on all of my pages.
The website is generated by sitebuilder and it protected with a .htaccess file.
Have you an idea or do you need more information?
Thanks for your help.
Hello, for a all-included SharePoint Analytics solution, please learn more and contact us here: SharePoint Analytics - Analytics Platform - Piwik