<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[SharePoint 'n stuff]]></title><description><![CDATA[SharePoint 'n stuff]]></description><link>https://tarmo.xyz</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Apr 2026 19:01:05 GMT</lastBuildDate><atom:link href="https://tarmo.xyz/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[About SharePoint analytics]]></title><description><![CDATA[When talking about SharePoint intranets of organizations big and small, the only way to get answers to a question of "Where my users really spend time on a daily basis" is either boring polls for the users, or actually knowing and keeping track where...]]></description><link>https://tarmo.xyz/about-sharepoint-analytics</link><guid isPermaLink="true">https://tarmo.xyz/about-sharepoint-analytics</guid><category><![CDATA[SharePoint]]></category><category><![CDATA[analytics]]></category><dc:creator><![CDATA[Tarmo]]></dc:creator><pubDate>Wed, 15 May 2024 20:43:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/shr_Xn8S8QU/upload/242b00d948e60039908b93c3062e6843.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When talking about SharePoint intranets of organizations big and small, the only way to get answers to a question of "Where my users really spend time on a daily basis" is either boring polls for the users, or actually knowing and keeping track where the users roam around in your intranet.</p>
<p>If you're reading this, then you probably know why you need this, but if not, here's the short version of why:<br /><em>You have a warehouse of information.</em><br /><em>But you don't know if anyone goes to read it.<br />Has anyone even read the company policy about the new staplers?</em></p>
<p>If you do not know what is used and what is not, then how do you decide what information to update and how often? Here's where you need analytics of course.</p>
<p><em>(FYI, SharePoint Online here only)</em></p>
<h2 id="heading-out-of-the-box-visuals">Out of the box visuals</h2>
<p>SharePoint has a built-in feature for analytics, but the only issue is that these analytics are pretty limited in terms of what the typical intranet power user would like to know, specifically to see more at once.</p>
<p>The usage analytics are accessible on the Site Usage - tab, behind the Settings - blade that opens from the cogwheel icon on top right:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1715795024283/f9bbfd7a-e325-4e55-b708-9182d1bafce0.png" alt /></p>
<p>Here, you'll find info about the current Site and the whole Hub (if applicable) by switching this dropdown on the right side of the page:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1715803022109/f0fc682c-7c40-4f45-8129-62c982829eaa.png" alt /></p>
<p>The collected data is limited to 90 days for a single site, and contains a few key metrics that show the user interest and engagement for the current site the analytics page was opened:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1715795179985/1ad5a484-8254-4d5e-8edd-0e272d2d7c6a.png" alt class="image--center mx-auto" /></p>
<p>On the Hub usage data - side, the available timespan is limited to just 30 days, and you have some few insights to your hubsite usage:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1715795482959/1ea8e38e-25a7-445b-ae59-b60b55f02ec1.png" alt class="image--center mx-auto" /></p>
<p>These can be very handy for most, since they collect info also about the popular contents on the hub, but what if you have a multihub-solution?</p>
<p>Now since we're talking about SharePoint, mostly all information can be dug up from the depths, and additionally using multiple ways.</p>
<p>Here's a few ways to get your hands dirty with analytics!</p>
<h2 id="heading-route-1-sharepoint-rest-api-v20-graph-api">Route 1 - SharePoint Rest API v2.0 // Graph API</h2>
<p>Back in 2019 the v2.0 REST api for SharePoint came to life (<a target="_blank" href="https://www.techmikael.com/2019/01/introducing-sharepoint-rest-api-v20.html">based on Mikael Svensons post</a>), and by using this api we can get almost the same basic analytics for single item.</p>
<p>Inside SharePoint, using for example <code>_api/v2.0/sites/{SiteID}/analytics/lastSevenDays</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1715796982018/9bd784ff-900d-4a51-8cc5-41c127331bda.png" alt class="image--center mx-auto" /></p>
<p>Or the same with Graph API <code>https://graph.microsoft.com/v1.0/sites/f92a8c43-f585-472b-b0a0-e0fdc8ef11b0/analytics/lastSevenDays</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1715803169613/d0aab068-300a-4665-95b1-03f06cfb3d81.png" alt class="image--center mx-auto" /></p>
<p>On response, we get data for visits (actionCount), unique users (actorCount) and time spent on item (timeSpentInSeconds).</p>
<p>You can try this easily, with the id of your sites home page, by going to <code>https://{Tenant}.sharepoint.com/sites/{Site}/_api/site/id</code> and then proceeding to call the analytics endpoints.</p>
<p>There are built in endpoints for:<br />- <a target="_blank" href="https://learn.microsoft.com/en-us/graph/api/itemanalytics-get?view=graph-rest-1.0&amp;tabs=http">Last week</a> - <code>_api/v2.0/sites/{SiteID}/analytics/lastSevenDays</code><br />- All time - <code>_api/v2.0/sites/{SiteID}/analytics/allTime</code><br />- <a target="_blank" href="https://learn.microsoft.com/en-us/graph/api/itemactivitystat-getactivitybyinterval?view=graph-rest-1.0&amp;tabs=http">Custom interval</a> - <code>_api/v2.0/sites/{SiteID}/getActivitiesByInterval(startDateTime='2024-01-01',endDateTime='2024-05-01',interval='day')</code></p>
<h2 id="heading-route-2-query-by-search">Route 2 - Query by Search</h2>
<p><a target="_blank" href="https://www.koskila.net/how-to-interpret-sharepoints-view-count-managed-properties-like-viewslast1days/">Antti Koskela has made an awesome post</a> about the Managed properties in SharePoint Online's search index, so you should definitely check that out for more info about these, since I won't explain it here. Even though the post is from 2019, the information is still relevant since the properties are still there and nothings changed.</p>
<p>I built a semi-quick sample solution around this article to utilize this way of analytics fetching, to view all the sites and pages in a hub:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1715799248919/bac007eb-8958-476b-acfc-2ce83affe4b6.png" alt class="image--center mx-auto" /></p>
<p>You can go get a copy of it from my <a target="_blank" href="https://github.com/tarzzi/webpart-analytics">Github - tarzzi/webpart-analytics</a> or go build something else based on it!</p>
<h2 id="heading-route-3-sharepoint-rest-api-v21">Route 3 - SharePoint REST API v2.1</h2>
<p>But wait, didn't we go trough this already? Nope, since there's more ways always, when you visit the analytics section, where does this data come from?</p>
<p>By looking at the Network - tab in Chrome DevTools, we find that the page is calling for example: <code>https://{tenant}.sharepoint.com/_api/v2.1/sites/{tenant}.sharepoint.com,f92a8c43-f585-472b-b0a0-e0fdc8ef11b0,20a382a6-aced-48b5-8f46-d155dfcbe11b/oneDrive.getActivitiesByInterval?startDateTime=2024-02-16T20:16:42.587Z&amp;endDateTime=2024-05-15T19:16:42.587Z&amp;interval=day</code><br />To retrieve relevant data.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1715800813366/71e76848-d0ea-4e80-8d82-a9c532ab20f5.png" alt class="image--center mx-auto" /></p>
<p>The first three <strong>.getActivitiesByInterval</strong> respond with the basic data (like the 2.0 endpoint) for the users and spent time, so this is the section for the current Site usage data, with different intervals:</p>
<pre><code class="lang-json"><span class="hljs-string">"aggregationInterval"</span>: <span class="hljs-string">"None"</span>,
<span class="hljs-string">"startDateTime"</span>: <span class="hljs-string">"2024-02-16T00:00:00Z"</span>,
<span class="hljs-string">"endDateTime"</span>: <span class="hljs-string">"2024-02-16T23:59:59Z"</span>,
<span class="hljs-string">"access"</span>: {
  <span class="hljs-attr">"actionCount"</span>: <span class="hljs-number">0</span>,
  <span class="hljs-attr">"actorCount"</span>: <span class="hljs-number">0</span>,
  <span class="hljs-attr">"timeSpentInSeconds"</span>: <span class="hljs-number">0</span>
},
</code></pre>
<p>The last two are for the Hub usage data<br /><strong>.GetAnalytics</strong> responds with the DwellTime metric:</p>
<pre><code class="lang-json"><span class="hljs-string">"lastSevenDays"</span>: {
    <span class="hljs-attr">"@oneDrive.timeSpentPercentageChange"</span>: <span class="hljs-string">"-70.749632533072023517883390490"</span>,
    <span class="hljs-attr">"aggregationInterval"</span>: <span class="hljs-string">"None"</span>,
    <span class="hljs-attr">"startDateTime"</span>: <span class="hljs-string">"2024-05-08T17:00:00-07:00"</span>,
    <span class="hljs-attr">"endDateTime"</span>: <span class="hljs-string">"2024-05-14T17:00:00-07:00"</span>,
    <span class="hljs-attr">"aggregateActivities"</span>: [
      {
        <span class="hljs-attr">"dimension"</span>: <span class="hljs-string">"DwellTime"</span>,
        <span class="hljs-attr">"key"</span>: <span class="hljs-string">"5/9/2024 12:00:00 AM"</span>,
        <span class="hljs-attr">"value"</span>: <span class="hljs-number">597</span>
      }
    ]
  }
</code></pre>
<p><strong>.GetHubAnalytics</strong> responds with the same data as the first three, but for the whole hub, not just the site.</p>
<pre><code class="lang-json">{
    <span class="hljs-attr">"@odata.context"</span>: <span class="hljs-string">"https://{tenant}.sharepoint.com/_api/v2.1/$metadata#sites('{tenant}.sharepoint.com%2Cf92a8c43-f585-472b-b0a0-e0fdc8ef11b0%2C20a382a6-aced-48b5-8f46-d155dfcbe11b')/analytics(lastSevenDays(),lastThirtyDays(),allTime(),itemActivityStats())/$entity"</span>,
    <span class="hljs-attr">"@oneDrive.isDataForAllAssociatedSites"</span>: <span class="hljs-string">"True"</span>,
    <span class="hljs-attr">"@oneDrive.aggregatedSitesCounts"</span>: <span class="hljs-string">"2"</span>,
    <span class="hljs-attr">"lastSevenDays"</span>: {
        <span class="hljs-attr">"@oneDrive.actionPercentageChange"</span>: <span class="hljs-string">"-41.73"</span>,
        <span class="hljs-attr">"@oneDrive.actorPercentageChange"</span>: <span class="hljs-string">"0"</span>,
        <span class="hljs-attr">"aggregationInterval"</span>: <span class="hljs-string">"None"</span>,
        <span class="hljs-attr">"startDateTime"</span>: <span class="hljs-string">"0001-01-01T00:00:00Z"</span>,
        <span class="hljs-attr">"endDateTime"</span>: <span class="hljs-string">"0001-01-01T00:00:00Z"</span>,
        <span class="hljs-attr">"access"</span>: {
            <span class="hljs-attr">"actionCount"</span>: <span class="hljs-number">74</span>,
            <span class="hljs-attr">"actorCount"</span>: <span class="hljs-number">1</span>
        }
    },
</code></pre>
<p>Of course there's also the most visited News posts and documents:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1715801908967/f0d88a2c-25a2-40d6-8967-658ac29b3c2a.png" alt class="image--center mx-auto" /></p>
<p>That form the most visited Site pages, for example getting the pages in the hub, and sorting them by unique visitors: <code>_api/v2.1/sites/{tenant}.sharepoint.com,f92a8c43-f585-472b-b0a0-e0fdc8ef11b0,20a382a6-aced-48b5-8f46-d155dfcbe11b/items?$filter=isof(%27oneDrive.Page%27)%20AND%20oneDrive.page/news%20eq%20null&amp;$expand=analytics($expand=lastSevenDays)&amp;$orderby=analytics/lastSevenDays/access/actorCount%20desc</code></p>
<p>I won't dive deeper into these, mostly because I'm lazy now, and these endpoints look too much of a hassle. But basically with this, we retrieve the items that match the filter and then use the analytics information from them to get usage data. I could see this pretty useful for some occasions!</p>
<h2 id="heading-route-4-third-party-solutions">Route 4 - Third party solutions</h2>
<p>There's probably more analytics tools that could track your SharePoint, but here are the usual suspects, at least in my books:</p>
<p><a target="_blank" href="https://github.com/pnp/sp-dev-fx-extensions/tree/main/samples/js-application-analytics">Google analytics</a> - The all-knowing<br />The all in one every movement tracker. Might cause GDPR issues if in Europe so watch out.</p>
<p><a target="_blank" href="https://learn.microsoft.com/en-us/clarity/third-party-integrations/sharepoint-integration">Microsoft clarity</a> - The GDPR-compliant<br />Great for a base look of your intranet status, but focuses mostly on user behaviour. You get a big picture or a slice, but hard to get anything in between, since top listings (most views, least views) are limited at 10 items.</p>
<p><a target="_blank" href="https://gitlab.lsonline.fr/SharePoint/sp-dev-fx-webparts/matomo">Matomo analytics</a> - The data protector<br />Boasts data protection all the way. Could have issues setting up to tenant, at least I remember I had, that one time I installed this solution.</p>
<h2 id="heading-how-to-utilize-this-data">How to utilize this data?</h2>
<p>Since the ready-made analytics feature can handle only the hub wide statistics or a single site, and no one has time to go trough all the sites day by day to see how the single site is performing, you can probably see why a custom analytics solution would be beneficial.</p>
<p>For inspiration, one way could be to make a PowerAutomate flow to loop trough the sites, and collect a list of these statistics, and then visualize that with PowerBI or Excel, or any reasonable data visualization option.</p>
<p>Or create a monstrosity of data hoarding and upload all the data daily to Azure and utilize the data platforming over there to get every inch out of that visitor data.</p>
<p>I tackled this problem with a <a target="_blank" href="https://github.com/tarzzi/webpart-analytics">SPFx webpart</a> that has an hub-wide site and page listing option, but the possibilities are endless as always.</p>
<p><em>Thanks for reading!</em></p>
]]></content:encoded></item></channel></rss>