Freigeben über


HOW TO: Retrieve Web Analytics report data using API

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(
                 "https://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:

image

And the Report name parameter is shown below:

image

Here’s what is returned

image

And here’s what you see from UI (WA report)

image 

Comments

  • Anonymous
    January 01, 2003
    Unfortunately, wasn't able to get this working with SummaryReport on 2010. Always got the "viewName" error. Anyone had success?

  • Anonymous
    January 01, 2003
    Nice post

  • Anonymous
    January 01, 2003
    Nice post, I'll need to try this out!

  • Anonymous
    January 01, 2003
    Nice Post. Do you know the client side API for Usage Analytic report data in SharePoint 2013 ?  I have a requirement to show the page views in custom developed apps. let me know your views if you can.

  • Anonymous
    January 01, 2003
    I have a question, is it possible to retrieve the same data as the "GetSearchReport" method, only via the client side? Im working on an office 365 instance of sharepoint 2013 - using Napa as my remote dev environment and trying to pull a list of the most searched terms by month.

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    November 13, 2012
    your post is very good . i have a question, how to get FAST Search Connector Crawl Log  or History? however the  CrawlLog Class methods is obsoleted , please help if you have any answer .

  • Anonymous
    April 10, 2013
    Hi raam, Web Analytics has been changed in SharePoint 2013 significantly. Please check out the followings articles for details. Haven't got chance to research how you can bring those limited reports in an app. technet.microsoft.com/.../ff607742.aspx technet.microsoft.com/.../jj219554.aspx

  • Anonymous
    March 05, 2014
    nice post,
    i need to get same in sharepoint2013,if u have code pls share.
    i know this feature is removed in Sp2013,it is merged with search service application.
    but i m not knowing how to get in SP2013.
    i tried below linked post but no use
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/06e00842-6517-443f-866f-f91eae396f17/how-get-toppageforpagereport-programmatically-in-sharepoint-2013?forum=sharepointsearch

  • Anonymous
    March 13, 2014
    Web Analytics Reports in SharePoint 2010

  • Anonymous
    May 06, 2014
    I also get the "viewName" error when accessing the SummaryReport. I'm tried the fixes described above

  • Anonymous
    August 05, 2014
    "Viewname" exception is always thrown when the report level and the report name is not compatible to each other.

  • Anonymous
    August 12, 2014
    Hello

    i am trying to find that index of each report where we can find exactly value.
    for example: as you described in above example about this report name "TopPageForPageReport" . so you can see in quick watch of result array that:
    [0,0] index of array shows the page url.
    [0,1] index of array shows the Site collection name.
    [0,2] index of array shows the exact value of number of page views
    [0,3] index of array -- i dont have any idea about this index value.

    so i want the complete information of all the reports that which field is showing what data.

  • Anonymous
    August 12, 2014
    I am trying to use the code above as mentioned, I am getting "the site not found at url http://urlofthesite" for result[0,0].. has anyone faced this issue?

  • Anonymous
    August 18, 2014
    Hi, i can´t get data. All the time return in first parameter object[0,0] => "Value cannot be null.rnParameter name: identityName". What did i wrong?

  • Anonymous
    November 06, 2014
    same as MM I am trying to use the code above as mentioned, I am getting "the site not found at url http://urlofthesite" for result[0,0].. has anyone faced this issue?

    Anyone found a solution?

  • Anonymous
    November 06, 2014
    found it !! The console application i was using was targeted to x86 rather than x64
    http://akshaykoul.com/pages/viewBlog.aspx?ID=2

  • Anonymous
    February 04, 2015
    Hi,
    Is it possible in SP 2013 get same data using CSOM ?

  • Anonymous
    February 09, 2015
    i tried the same code, but its always the result showing null while debugging, please help me how to solve that

  • Anonymous
    May 07, 2015
    Can I get this DLL in the SDK? Or does anything using it have to run on the same computer that SP2010 is installed on? I installed the 2010 SDK, but didn't see it.

  • Anonymous
    July 22, 2015
    What language is this?

  • Anonymous
    January 13, 2016
    Is this possible for CSOM (.Net/Jquery) as well?