I have a requirement for getting the count of visitors who visits a SharePoint site in a year and as well as in a month. I want to display the result as a webpart in the homepage. Also I want to create another webpart to display the details of total visitors including name and profile picture. Can you please help me to complete these two webpart ? Thanks in Advance


To display the count of unique users for site, you may need to develop a web part to get the unique users for site from usage report programmatically, then display the data.

In SharePoint 2013, usage report can be obtain programmatically using SearchServiceApplication class, from Microsoft.Office.Server.Search.dll.

There are two methods available for these:



A demo code which retrieves the daily and monthly usage reports of Unique Users count:

 using (var site = new SPSite(siteId))
         var context = SPServiceContext.GetContext(site);
         var searchProxy = context.GetDefaultProxy(typeof(SearchServiceApplicationProxy)) as       SearchServiceApplicationProxy;
         var usageData= searchProxy.GetRollupAnalyticsItemData(1,Guid.Empty,site.ID,Guid.Empty); 

Some blogs about retrieving the reports programmatically:

How to retrieve reports programmatically in SharePoint 2013

How to get Search Analytics Reports programmatically in SharePoint 2013

An example about how to display the number of view count in SharePoint 2013

It is difficult to get the visitors who access the site in SharePoint 2013. You may need to parse the IIS logs using LogParser. Analyze logs to find the visitors.

Here is a custom tool to analyze IIS logs and get visitors for SharePoint sites by analyzing IIS logs:


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.