Customizing Web Analytics in SharePoint

From quite some time, I was trying to find ways to customize the SharePoint 2010 Web Analytics to capture the usage of Internal SharePoint solutions.

With SharePoint Web Analytics,  Users will be able to find the following three categories of reports out of the box from SP2010 (More Details) but I wanted to find out the customization details of this functionality so I can capture the data my way and create my own reports.

Traffic Reports:

  • Number of Page Views
  • Top Referrers
  • Top Visitors
  • Number of Daily Unique Visitors, Top Destinations, Top Browsers, etc.

Search Reports

  • Top Queries
  • Number of Queries 
  • Failed Queries
  • Best Bet Usage, Search keywords, etc.

Inventory reports:

  • Total disk drive space usage
  • Number of Site Collections 
  • Top Site Product Versions, Top Site Languages, etc.

The web analytics data comes from the request usage & It implements a usage receiver. From reflector we can see that SPUsageReceiver is an abstract class and we can write our own solution to override this class. We can create an usage receiver so that we can check every incoming request and store the statistics that we would like to. The receiver is going to be called when Usage Import job is executed.

image

Custom Usage Receiver

    1: class CustomSPRequestUsageReceiver : SPUsageReceiver    
    2: {         
    3:     public override void UsageImported(SPUsageReceiverProperties usageProperties)         
    4:     {                 
    5:         while (usageProperties.UsageEntries.MoveNext())                 
    6:         {                     
    7:             SPRequestUsageEntry entry = usageProperties.UsageEntries.Current as SPRequestUsageEntry;                    
    8:             
    9:             // You may write your custom logic here to access the entries per the custom requirement                 
   10:         }         
   11:     }     
   12: } 
  

You can register your custom usage receiver like below,

    1: SPRequestUsageDefinition definition = SPRequestUsageDefinition.Local; 
    2:  
    3: definition.Enabled = true; 
    4:  
    5: definition.EnableReceivers = true; 
    6:  
    7: definition.Receivers.Add(typeof(CustomSPRequestUsageReceiver)); 
    8:  
    9: definition.Update(); 
  

Comments

  • Anonymous
    February 10, 2011
    CardioLog analytics and usage reports was specifically designed for SharePoint Internal Portals. It provides in-depth detail and insight into portal growth, portal visitors, portal navigation and search, which do not exist generically in MOSS 2007 or SharePoint 2010.  CardioLog provides SharePoint 2010 usage stats such as drill down, site overlay, geotrending, content filtering by page metadata and tags, and much more.   See CardioLog's <a href="www.intlock.com/.../CardioLog-vs-SharePoint-Reports.asp">Competitive Advantage</a>

  • Anonymous
    February 14, 2011
    Thank you for this - I need to extend the basic logging to include organisation ID and this has actually made it possible. The only problem I'm getting is that when trying to update the usage definition, despite running with elevated privileges, I'm getting an Access Denied error and the UsageImported event doesn't seem to trigger or register. Any ideas?

  • Anonymous
    February 27, 2011
    HI , we have a extranet sharepoint 2010 site. anonymous people will visit. i need to categorize the anonymous users into new user frequent user and infrequent users. i followed below link to achive this.. blog.mastykarz.nl/content-targeting-anonymous-users-sharepoint-server-2010-part2-2 now we are able to target the content to the categoriezed user.. instead of profile DB ., i used cookie to decide category of the user. now we need to generate reports for the same. can sharepoint 2010 web analytics helps? or shall we go for google analytics? can we customize reports? need a gudlines and help from you.. how can use web analytics or google analytics to achieve the same requiremnt.? suggestions and guidlines are needed . help

  • Anonymous
    May 07, 2012
    hello, is very interesting this article, but i search a specific point, in Web Analytics page, i try create one new link in Web Analytics page, (not web page), and of course display my chart, I can edit this part?

  • Anonymous
    August 29, 2012
    So any way to get specific page hit trends without writing a custom event receiver?

  • Anonymous
    January 15, 2014
    good post