How to track SharePoint usage with Google Analytics

Google Analytics is the number one tracking tool in the internet and despite have not being designed to be used in intranets it works perfectly with SharePoint.

In this post you will learn how you can easily install Google Analytics on modern sites in SharePoint Online, this solution has support for the new Google Analytics 4.

Add Google Analytics V4 to SharePoint

How to add Google Analytics to SharePoint

The solution use here is available in the PnP GitHub repository however it needs to be compiled in order to get installed in your tenant. In this article I’m providing you the installation package ready to be used in your tenant, to do it please follow the instructions below:

  1. Start by download the installation file from here
  2. Open your global app catalog if you want to monitor all the modern site collections in your tenant or the local site collection app catalog if you just want to monitor an individual site collection. To learn more about the differences between the site collection app catalogs have a look here.
  3. Upload the solution to the app catalog
  4. In the deployment pop-up make sure you select the option Make this solution available to all sites in the organization, this option will deploy the solution automatically without the need to manually add the app
    Add Google Analytics V4 to SharePoint
  5. The Google Analytics solution is provided with 3 custom properties that need to be configured to get start tracking your pages.
    • If you are installing the solution in the global app catalog the Tenant Wide Extensions is available directly from the Site Contents.
    • If you are installing it in a site collection, the Tenant Wide Extensions list is hidden and you need to use the following URL adjusted to your tenant and site collection URL https://contoso.sharepoint.com/sites/projectx/Lists/TenantWideExtensions/AllItems.aspx.
  6. Edit the item with the title Analytics
  7. Replace the Component Properties Value by the following code
    {"trackingId":"UA-00000000-1","disableAsync":false,"googleAnalyticsV4":true}
  8. Replace the value in the trackingId property by your Google Analytics code
  9. If your organization does not primarily use modern browsers to access your SharePoint tenant, you can default to the non-asynchronous script loading method by changing the property disableAsync value from false to true
  10. Ig your tracking code starts with G- it means you are already using Google Analytics 4, in this case change the property googleAnalyticsV4 value from false to true
  11. Click Save
    Add Google Analytics V4 to SharePoint

From this moment on your SharePoint environment is being tracked by Google Analytics as shown in the following image.

Add Google Analytics V4 to SharePoint

Other Google Analytics scenarios and solutions for SharePoint Online and SharePoint On-Prem

I’ve writing and building solutions to integrate Analytics in SharePoint for a few years now, if you are looking for a solution for a SharePoint version that is not covered by this article, please have a look to the following list:


No comments yet

Leave a Reply


I've been working with Microsoft Technologies over the last ten years, mainly focused on creating collaboration and productivity solutions that drive the adoption of Microsoft Modern Workplace.