How to get item page views using sitecore 6.5 Analytics API
We are trying to use Sitecore Analytics API to retrieve total number of page views for each page but not quite sure how to use the API to retrieve this info. Previously, when working on similar functionality in Sitecore 6.2, I believe the Analytics开发者_运维问答 API was not complete and we had to query the database directly. But now, I've read that Sitecore 6.5 has a better and extensive API support for Analytics, but couldn't find proper documentation to achieve this functionality. Do we still need to query the db directly or can we do it via API? We are looking for a method or logic to retrieve total no. of page view count for specific page/item by passing in the item id. Please suggest.
You are correct in thinking the Analytics API has been improved dramatically. You should be able to access the data you want using something similar to:
Sitecore.Analytics.Data.DataAccess.DataSets.VisitorDataSet.PagesDataTable pagesDataTable = new VisitorDataSet.PagesDataTable();
int pageViews = pagesDataTable.Count(p => p.ItemId == <Your ItemId>);
.. hope this helps.
精彩评论