1

I am writing server-side code to get the number of likes for each item in the Post list for each site.

SPSite site = new SPSite(siteUrl);
int countBlogs = 0;
int countPosts = 0;

foreach (SPWeb web in site.AllWebs)
{
    foreach (SPList list in web.Lists)
    {
        if(list.Title == "Posts")
        {
            Console.WriteLine("BLOG FOUND by" + list.Author);
            countBlogs++;
            foreach (SPItem item in list.Items)
            {
                Console.WriteLine("ID: {0} \nTitle: {1} \nLikes: {2} \n\n", item.ID, item["Title"], item["Number of Likes"]);
                countPosts++;
            }
        }       
    }  
}
Console.WriteLine("Total Blogs: {0} \nTotal Posts: {1} ", countBlogs, countPosts);

It is a basic iteration through all the Sites within a Site Collection. I have searched a lot for a way to get the number of views for each blog post but I couldn't find something useful. The out of the box Popularity Trends is not exactly what I need. In the end, I want to display the top viewed items in the list Posts.

  • I followed your directions and I don't see the site analytics reports under Site Actions. Is this a configuration issue? – Mdtimetraveler Feb 14 at 16:17
2

Inside of the blog site settings. Go to site actions Then site analytics reports then top pages.

Please refer to the below link:

View and configure usage analytics reports in SharePoint Server 2013

How to find your document hits on SharePoint 2007

Find the most visited sites in SharePoint 2013

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.