I need to know who visits a site collection and I was looking for a way to get information about the visitors such as: user, ip, etc.

I thought to use Google Analytics, but there's no way to registry the user name, for example. I checked that Sharepoint lets us to generate custom reports but these reports take a big amount of time to be generated.

So, to do what I need, I thought to develop a WCF service to record every visit into a DB with some relevant information and to use Power BI to show and to link relevant information.

What do you thing about this approach? Any suggestion?


I believe the power of SP is in partner solutions, but I'm not a dev, but integrator, so this opinion may be skewed. Packaged solutions are easier to sell to DMs than dev-hours, and effect is immediate.

After estimating the cost of developing that kind of 'Google Analytics' in the latest project I ended up using the free version of http://www.intlock.com/products/sharepoint-office365-analytics/overview/. It's installed on a separate server, and tracking is done with js-code that can be manually put on masterpage/CEWP or deployed thru SharePoint solution.

Maybe you should try that.


You can use google Analytics, just need to set the username in customvar, here is an example.

Using jquery, jquery cookie plugin, jquery spservices.. In Google Analytics you can use the customvar1 in custom reports..

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
    _gaq.push(['_setDomainName', 'XXXXXXXXXXXX.com']);

    // Get Username, try from session cookie first

   var savedName   = $.cookie("svName");
   if ((savedName==null)||(savedName=="")) 
    savedName =  $().SPServices.SPGetCurrentUser({fieldName: "Name",async:false,debug: false);
    $.cookie("svName",savedName, { path: '/' });

    // Set Google Analytics Custom Var      
    _gaq.push(['_deleteCustomVar', 1]);
      1,                   // This custom var is set to slot #1.  Required parameter.
      'SPUser',           // The top-level name for your online content categories.  Required parameter.
      savedName,3        // Sets the value of "SPUser"   Required parameter.


  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);




You can't use Google Analytics for this scenario. Even though a customvar solution will technically work, the GA Terms of Service prohibits you from uploading usernames or other PII to your GA reports.

The data you want to see (username, IP address, etc.) is contained in the IIS logs for the site collection. You can find the folder that contains the logs by looking at the Site ID for the site collection, and then finding the "W3CSVC(siteid)" folder under the IIS logs directory.

From there, you'll probably need to run the logs through a web analytics software package that works with SharePoint. If you want to sessionize the data by username, you need something more powerful than a freeware/basic log analyzer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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