I have a site collection with number of sub sites. I want to generate a report based on the count of hits(In terms of each and every click or any other operation performed) for each and every sub site of the site collection including the top level site.

How can I get this information using object model? Or is there any out of the box scenario for this? I need to extract the number of hits for each individual subsite through programming itself.For eg: The generated reports should look like:-Site Usage Report

Please guide us.

1 Answer 1


This blog has the answer to your question. The code generates site hit reports for the past 30 days. If you review the code given in this blog then I believe it meets your needs.

Report for site hit count in SharePoint

The other alternate is to use an available sandbox solution on MSDN code: Create Custom hit counter in SharePoint 2010 using Sandbox Solution

To use this MSDN code follow the below steps:

Step 1: Create a Visual Web Part and copy the code inside Page_Load(object sender, EventArgs e) as same as they did inside Render() Method.

Step 2(Optional): Add the following code if you want to record Client IP address with User, Data & URL.

enter image description here

Step 3: Deploy Hit counter using command (Powershell or STSADM) or VS 2010 to this site

Step 4: Create a Custom List, name it as Statistics or Record List also create three or four columns in Statistics list as like as below:

  1. Url - Multiple lines of text

  2. Date - Single line of text

  3. Username - Single line of text

  4. IP - Single line of text

Step: 5: Add this web part on the home page. To count the hit for all pages in site, you have to place the web-part in all master page, so that the web-part code runs on every page where the visitor go and makes the unique entry in Statistics list.

  • Please add more details to your post (like the actual code), off course with a the link as source. If the link breaks your answer will be of no help to future readers. Sep 1, 2014 at 8:26
  • @ZakirHC can this be done using powershell code instead? Mar 26, 2018 at 15:16

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.