Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Share point 2010 - Using Web Analytic Reports programmatically

2.50/5 (2 votes)
23 Dec 2011CPOL 21.1K  
Capturing Web Analytic reports via out of the box dlls(classes)

Introduction

Lately I've been asked to capture Web Analytic Reports data from Microsoft Share point 2010 programmatically. As far as I searched on web all the answers were related to acquire the data from Database, which in this article I'm not going to focus on this approach instead I'm going to use out of the box classes which are related to Web Analytic Reports. The codes are all in c# language. 

Background

All you need is VS2010 and SHAREPOINT 2010 installed.

Using the code

To use the Web Analytic Reports data we need to add explicit reference to following dynamic link libraries (shortly dll):

Microsoft.Office.Server.WebAnalytics

Microsoft.Office.Server.WebAnalytics.UI

There is a method called AnalyticsReportFunction  which gets all of the data for us. This is the main code which get the data for us:

C++
Microsoft.Office.Server.WebAnalytics.Reporting.AnalyticsReportFunction a =
                            new Microsoft.Office.Server.WebAnalytics.Reporting.AnalyticsReportFunction();
C++
foreach (AggregationLevel itm in Enum.GetValues(typeof(AggregationLevel)))
 {
    lstRepLevel.Items.Add(new ListItem(itm.ToString(), itm.ToString()));
 }
foreach (ReportType itm in Enum.GetValues(typeof(ReportType)))
{
    lstRepTypes.Items.Add(new ListItem(itm.ToString(), itm.ToString()));
}
C++
object[,] res = a.GetWebAnalyticsReportData(TxtSiteUrl.Text, reportLevel,reportType,DateTime.Parse(txtFromDate.Text),
                        DateTime.Parse(txtToDate.Text));



All the best.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)