This blog post is a contribution from Aaron Miao, an engineer with the SharePoint Developer Support team.
In a scenario that you want to render Web Analytics report data to your favorite format, you need to retrieve the report data. There’s no document on how to retrieve SharePoint built-in report data. Some online articles are suggesting retrieving data directly from Web Analytics reporting database. It’s not recommended. Even with this approach, often customer faces issue of getting AggregationId which is required to retrieve data from database.
Here’s the sample code that can be used to retrieve Web Analytics report data.
AnalyticsReportFunction ar = new AnalyticsReportFunction();
object[,] result = ar.GetWebAnalyticsReportData(
"2", // Report level,
"TopPageForPageReport", // Report name,
DateTime.Today.AddDays(-30.0), // Start date,
DateTime.Today); // End date,
In the above, the Report level parameter is shown below: