Showing SharePoint User and Page in Azure Analytics RRS feed

  • Question

  • I have set up Azure Insights for a SharePoint site per the following procedure:

    I actually set up the more involved script at the bottom in hopes of returning user information, but in fact, I'm still just seeing generic information on my Insights Dashboard in Azure.

    My question is, how can I see the user's name (or username) and the exact page hit in the Events from my Azure Insights dashboard.

    The screenshot shows my current view. As you can see, the User ID is just a random ID, and the events are just the site name, not the page name.

    Monday, June 25, 2018 3:29 PM

All replies

  • I was looking through documentation (and there's a lot of it) to try and find something that would answer your question.  On my first pass, I did find this which hopefully will get you a bit closer to your answer:

    List specific users and their usage

    If you just want to search for specific users, you can set the authenticated user id.

    If you want a list of users with data such as what pages they look at or how often they log in, you have two options:

    • Set authenticated user idexport to a database and use suitable tools to analyze your user data there.
    • If you have only a small number of users, send custom events or metrics, using the data of interest as the metric value or event name, and setting the user id as a property. To analyze page views, replace the standard JavaScript trackPageView call. To analyze server-side telemetry, use a telemetry initializer to add the user id to all server telemetry. You can then filter and segment metrics and searches on the user id.

    Friday, June 29, 2018 6:11 PM
  • Could you run a query in analytics to see if the events/page view telemetry actually have the custom attributes you are setting (with the more involved script) on the client side?

    pageViews | take 1

    customEvents | take 1

    Wednesday, July 11, 2018 6:13 PM
  • I do this to capture the screen resolution and actual domain name as custom properties which can be filter against

    function AppInsightsUtils() { };
    AppInsightsUtils.initialize = function () {
    	var currentUser;
    	SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
    	function sharePointReady() {
    		var context = new SP.ClientContext.get_current();
            var web = context.get_web();
            currentUser = web.get_currentUser();
    	    context.executeQueryAsync(onRequestSuccess, onRequestFail);
    	// This function runs if the executeQueryAsync call succeeds. 
    	function onRequestSuccess() { 
    	var appInsights=window.appInsights||function(config){
    	function s(config){t[config]=function(){var i=arguments;t.queue.push(function(){t[config].apply(t,i)})}}var t={config:config},r=document,f=window,e="script",o=r.createElement(e),i,u;for(o.src=config.url||"//",r.getElementsByTagName(e)[0].parentNode.appendChild(o),t.cookie=r.cookie,t.queue=[],i=["Event","Exception","Metric","PageView","Trace"];i.length;)s("track"+i.pop());return config.disableExceptionTracking||(i="onerror",s("_"+i),u=f[i],f[i]=function(config,r,f,e,o){var s=u&&u(config,r,f,e,o);return s!==!0&&t["_"+i](config,r,f,e,o),s}),t
    		appInsights.queue.push(function () {
    				appInsights.context.addTelemetryInitializer(function (envelope) {
    					envelope.tags = envelope.tags || {};
    					if (typeof screen !== "undefined") {
    						envelope.tags["device.screenResolution"] = screen.width + "X" + screen.height;
    						envelope.tags["device.locale"] = navigator.language || navigator.browserLanguage || "unknown";
    		var account = currentUser.get_loginName();
            var currentUserAccount = account.substring(account.indexOf("|") + 1);
    		appInsights.trackPageView(document.title,window.location.href, {User: currentUserAccount,Screen:screen.width + "x" + screen.height});
    	// This function runs if the executeQueryAsync call fails. 
    	function onRequestFail(sender, args) { 
    hope that helps

    Friday, September 13, 2019 10:31 AM