Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am working on custom solution that works like a blog. I have a list that contains articles, and I have publishing page that takes the list item id in the URL and query the list to display it.

Now I want to display the hit counter for each article, which is an item in list. Is there an OTB feature in SharePoint Web Analytics, or should I implement it myself by updating the list item with its hit count each time it is retrieved?

share|improve this question
    
I'm trying to achieve the same thing. Can you share your solution? –  user11362 Oct 16 '12 at 1:17

2 Answers 2

You can get usage data of the respective SPWeb, and filter out the statistics of a specific list item.

DataTable usageDt = SPContext.Current.Web.GetUsageData(SPUsageReportType.url, SPUsagePeriodType.lastMonth);

foreach (DataRow dr in usageDt.Rows)
{
    if(dr["Page"].ToString().ToLower().Equals("myitem.docx"))
    {
        Response.Write("Page: " + dr["Page"].ToString().ToLower() + " Hits: " + dr["Total Hits"].ToString());        
    }
}

Note that GetUsageData only returns 2000 records from the usage data for the site. If you run into that limitation, GetUsageBlob needs to be used (don't have experience of that).

share|improve this answer
    
Thanks Jussi, but this didnt work with me as it returned the hits for the pages, but not the list items –  shobani Feb 18 '12 at 1:15
up vote 1 down vote accepted

I did not find a solution OTB, so I decided to go with a custom solution.

I am adding new Column "Hit Counter" on the list, and updating it each time the post is loaded.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.