locked
How to increase ViewsLifeTime / ViewsRecent managed propereties via REST API call? RRS feed

  • Question

  • Hi there,

    we are using sharepoint 2013 as a content solution to store documents or lists. On top of it we use a custom WEB application that calls sharepoint on the backend and displays content. This means that we only do calls via REST API and don't download any master pages or display pages.

    Issue lays in the way sharepoint counts views. It increases those values only if you display an item via Display.aspx?ID=(ItemID) which we don't want. Is there a way to make sharepoint increase the number of views via REST API? 

     REST API CALL TO X LIST FOR Y ITEM -> ViewsRecent++

    Thanks for any help.

    Roman


    • Edited by xsustek Monday, November 14, 2016 9:32 PM
    Monday, November 14, 2016 9:04 PM

All replies

  • Hi Roman,

    Here is teh link

    http://sharepoint.stackexchange.com/questions/112779/sharepoint-2013-page-views


    Please remember to click Mark as Answer on the answer if it helps you

    Monday, November 14, 2016 10:10 PM
  • Hi Roman,

    I dont think even if you issue a POST AJAX request using REST API, the view counts will not increase. This is because the call goes to Client.svc WCF service located in the 15 hive file structure and it gets the data directly from the Content Database. There is no page refresh/post back happening here. 

    Thanks,

    Priyan



    Please Up Vote and Mark this as Answer if it helps.

    Tuesday, November 15, 2016 3:19 AM
  • Hello Priyan,

    thanks for the post. Do you have any suggestions how we could increase that value without the need for callying a full display template ? The display.aspx templates basically loads the whole master page and all files necessary to show a full sharepoint page. This is a lot of data, and we'd like to minimal API call. If it cannot be via REST API? Would you recommend a different approach?

    Tuesday, November 15, 2016 7:33 PM
  • Hi,

    Unless you invoke a page refresh which causes a post back, the hit count will not increase. REST API,SharePoint object model calls will not increase page hit count.You can open the page in a new tab programatically and close it which is obviously a dirty approach. 

    Thanks,

    Priyan


    Please Up Vote and Mark this as Answer if it helps.

    Wednesday, November 16, 2016 7:30 AM
  • How about doing something like this 

    //Log Views usage event on URL of catalog item
        window.LogViewsToEventStore = function(url, site)
        {    
            SP.SOD.executeFunc(“sp.js”, “SP.ClientContext”, function()
            {
                var spClientContext = SP.ClientContext.get_current();
                if(!$isNull(spClientContext))
                {
                        var spWeb = spClientContext.get_web();
                        var spUser = spWeb.get_currentUser();
                        var spScope = “{00000000-0000-0000-0000-000000000000}”;
                        
                        //Event ID = 1 (Views), 2 (
                        SP.Analytics.AnalyticsUsageEntry.logAnalyticsEvent2(spClientContext, 1, url, spScope, site, spUser);spClientContext.executeQueryAsync(null, null);                   
                }
            });
        };
        
        LogViewsToEventStore(‘Url’, ‘SiteID’);

    https://therelentlessfrontend.com/2014/02/06/sharepoint-2013-log-analytics-through-javascript/

    The question is how could you call that function from user's browser and what other componets you need to load from shareopoint to be able to do that java call.

    Any ideas?



    • Edited by xsustek Friday, November 18, 2016 4:13 PM
    Friday, November 18, 2016 4:12 PM
  • Hi Roman, did you ever find a solution to this?

    Regards,

    Dave

    Friday, August 7, 2020 1:13 PM