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?

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

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)
        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).

  • 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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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