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.


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;                    
   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; 
   3: definition.Enabled = true; 
   5: definition.EnableReceivers = true; 
   7: definition.Receivers.Add(typeof(CustomSPRequestUsageReceiver)); 
   9: definition.Update(); 

Comments (6)

  1. SharePoint Usage says:

    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="…/CardioLog-vs-SharePoint-Reports.asp">Competitive Advantage</a>

  2. James says:

    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?

  3. guru says:

    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..

    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

  4. question says:

    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?

  5. Peter says:

    So any way to get specific page hit trends without writing a custom event receiver?

Skip to main content