First published on TECHNET on Oct 04, 2012
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.
using Microsoft.Office.Server.WebAnalytics.Reporting;
AnalyticsReportFunction ar = new AnalyticsReportFunction(); object[,] result = ar.GetWebAnalyticsReportData( "http://yoursiteurl/", "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:
And the Report name parameter is shown below:
Here’s what is returned
And here’s what you see from UI (WA report)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.