0

I have a page created on a SharePoint site, on which a video has been embedded. I have full control over that site collection only. No access to Central Admin.

Is there a way where I can know, how many users have viewed that video? (with their names, if possible)

I ran a Audit Log Report from Site Settings. But the page where the video is embedded doesn't come up in the result.

Any advise?

Thanks

  • Google analytics? – Taran Goel Dec 21 '15 at 14:40
  • cannot implement that.... but still.. it will show future data. I will need data on how many users have already seen the video. – SP_Tech Dec 21 '15 at 15:05
2

The easiest way is to create a Custom List and make every pageview create a new Item in that list.

  • The Title gets the pagename (serverRequestPath)
  • The Created/Created By info is automatically assigned

Obfuscation (because you are playing Big Brother)

Users need create rights on the List, you could also

  • limit access so they can only read their own entries
  • Make the default View an empty view

Recording each pageview

I usually do not promote jQuery, but in this case jQuery ajax solves a whole load of potential browser issues

    /*global document,window,navigator,console*/
    /*global SP,$,_spPageContextInfo*/
    /*jshint -W030*/ //allow expression assignments
    SP.SOD.registerSod('CDNJQ', "https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js");
    SP.SOD.executeFunc('CDNJQ', null, function () {
        try { //extra try catch to not hold on CORS errors
            var trackError = function (jqXHR, textStatus, errorThrown) {
                console && console.log('trackPage', textStatus, errorThrown);
            };
            var trackSite = '/.', //default root SiteCollection
                trackList = 'NAME_OF_YOUR_TRACKING_LIST';
            var item = {
                '__metadata': {
                    'type': 'SP.List'
                },
                'Title': _spPageContextInfo.serverRequestPath
            };
            $.ajax({
                url: trackSite + "/_api/contextinfo",
                type: "POST",
                headers: {
                    "Accept": "application/json;odata=verbose"
                },
                success: function (contextData) {
                    $.ajax({
                        url: trackSite + "/_api/web/lists/getbytitle('" + trackList + "')/items?@target='" + trackSite + "'",
                        method: "POST",
                        contentType: "application/json;odata=verbose",
                        data: JSON.stringify(item),
                        async: true,
                        headers: {
                            "Accept": "application/json;odata=verbose",
                            "X-RequestDigest": $("#__REQUESTDIGEST").val()
                        },
                        success: function (data) {
                            console && console.log('trackPage success');
                        },
                        error: trackError
                    });
                },
                error: trackError
            });
        } catch (e) {
            console.error(e);
        }
    });

Notes

  • Link from a CEWP or JSlink or put into SEWP or MasterPage
  • Nested Ajax call is a remnant from some more complex implementation

iJS JX

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.