I'm currently running Sharepoint 2013 Enterprise and would like to know the following:

  • Which pages each user has accessed over the last X Days

  • How much time each user has spent on each page (can't average, I need to know per user)

Like Google Analytics, but at a "user" level. Any clues on how to do that?

I searched a lot on stackoverflow and found nothing. Maybe I'm using the wrong terminology.

I know that Google Analytics may be an option, but I don't know if I can pass the username or the Name of each user to Google. I heard that it is against their Terms of Use.

3 Answers 3


Turn on Usage and Health data collection. This is your first step. This will get you data on which pages users access. This will all be stored in the Usage Database. The Usage database is the ONLY database microsoft will support you modifying for your use. Once logging is enabled you can run custom queries or reports from the Usage data base to get the different aggregates for users (the default reports to do this for all users).

You can also get this from inside SharePoint if you enabling auditing across your site collections. You will then get some excel reports showing which users accessed which items and you can again customize for grouping as you need. These are more difficult to work with as you have to go to each site to get them. Even scripting it is a bit tedious.

As far as time on each page - there is nothing that tracks that. You need to add that functionality your self as well as a method for storing it. It is supported to log this type of activity to the Usage database so you can report on it. How you would implement that I'm not sure. You could use a custom HTTP handler to monitor requests between pages and log the time difference or possibly track it via a client side cookie.


You are correct, Google doesn't allow you to store usernames in Google Analytics. You can also run into problems if the tracking request is blocked at the firewall.


Sorry for the bad news, but you can't see what you're looking for with Google Analytics.


Try this out:

<script type="text/javascript"><br/>
//get user name<br/>
 var userid= _spPageContextInfo.userId;<br/>
  var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";<br/>
  var requestHeaders = { "accept" : "application/json;odata=verbose" };<br/>
    url : requestUri,<br/>
    contentType : "application/json;odata=verbose",<br/>
    headers : requestHeaders,<br/>
    success : onSuccess,<br/>
    error : onError<br/>
   var loginName;<br/>
  function onSuccess(data, request){<br/>
    loginName = data.d.Title;<br/>
  function onError(error) {<br/>

//add an event action<br/>

var trackOutboundLink = function(url) {<br/>
 //concat the url that you set on "click" with loginName<br/>
   var urlfinal = "URL: " + url + "Login Name: " + loginName;<br/>
   ga('send', 'event', 'outbound', 'click', urlfinal, {<br/>
     'transport': 'beacon',<br/>
     'hitCallback': function(){document.location = url;}<br/>
   });  <br/>

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.