> ## Content Index
> Fetch the complete content index at: https://blog.lsonline.fr/llms.txt
> Use this file to discover other available public pages before exploring further.

# Setup Google Analytics to Modern SharePoint from any platform
- URL: https://blog.lsonline.fr/2019/02/07/setup-google-analytics-to-modern-sharepoint-from-any-platform/
- Published: 2019-02-07T17:24:41.000Z
- Updated: 2026-01-27T18:42:45.000Z
- Description: Implement Google Analytics to your Modern SharePoint sites from any platform
- Author: Laurent Sittler
- Tags: SharePoint Framework, Analytics, SharePoint, Modern Experience, Development, Microsoft Patterns & Practices, CLI for Microsoft 365, PowerShell, Microsoft 365

[**Google Analytics**](https://marketingplatform.google.com/about/analytics?ref=blog.lsonline.fr) is a web **analytics** service offered by **Google** that tracks and reports website traffic. SharePoint provides some reports too, but these ones can be quickly insufficient if you need more KPI.

Previously, on the classic experience of SharePoint, it was possible to add Google Analytics script by:

- Creating a Master Page and including the script (it was not a Best Practice by the way 😁)
- Creating a Custom Action

> Fast forward to today, modern SharePoint experiences support the most common scenarios that organizations use SharePoint for. Many organizations have already switched to using modern experiences, and many more are evaluating how they would benefit of modernizing their intranets.

[Setup SharePoint Starter Kit from any platformSharePoint Starter Kit allows you to test-drive modern SharePoint experiences on your own tenant, and now you can set it up from any platform.![](https://blog.mastykarz.nl/favicon.png)Waldek MastykarzWaldek Mastykarz![](https://blog.mastykarz.nl/assets/images/2019/01/banner.png)](https://blog.mastykarz.nl/setup-sharepoint-starter-kit-any-platform?ref=blog.lsonline.fr)

That is totally true! How to visualize in real-time or through a complete dashboard several native and custom KPI? 

![](https://blog.lsonline.fr/content/images/2021/01/ga-logo-new-3.png)

In addition, you can access several features for FREE.

## Google Analytics for Modern SharePoint - for everybody

So, now... How to set up this solution for your Modern SharePoint sites? This subject has already been addressed in the post of [Joao Ferreira](http://handsonsharepoint.net/about?ref=blog.lsonline.fr).

What can I bring more to that?

1. Upgrade his solution to use the latest version of [SharePoint Framework](https://github.com/pnp/generator-spfx?ref=blog.lsonline.fr)
2. Perform some enhancements
3. Allow you to deploy the solution from any platform thanks to [Office365-CLI](https://pnp.github.io/office365-cli?ref=blog.lsonline.fr). If you too, are a macOS user and working on several SharePoint solutions yourself, you want to have a way to provision Google Analytics, without having to use a VM or a Windows computer
4. Create scripts to implement the solution easier

## Google Analytics implementation

I wrote two scripts that will allow you to implement the solution easily.

### Prerequisites

1. Google Analytics Tracking ID: [https://support.google.com/analytics/answer/1008080](https://support.google.com/analytics/answer/1008080?ref=blog.lsonline.fr)
2. Tenant App Catalog or Site Collection App Catalog:  
  - Configure your Tenant App Catalog: [https://docs.microsoft.com/en-us/sharepoint/use-app-catalog](https://docs.microsoft.com/en-us/sharepoint/use-app-catalog?ref=blog.lsonline.fr)
  - Configure your Site Collection App Catalog *(optional)*: [https://docs.microsoft.com/en-us/sharepoint/dev/general-development/site-collection-app-catalog](https://docs.microsoft.com/en-us/sharepoint/dev/general-development/site-collection-app-catalog?ref=blog.lsonline.fr)
3. If you choose to use **PowerShell** solution, you'll need to install the **[PnP PowerShell module](https://github.com/SharePoint/PnP-PowerShell/releases?ref=blog.lsonline.fr)**
4. If you choose to use **any platform** solution, you'll need **Bash** and **[Office365-CLI](https://pnp.github.io/office365-cli?ref=blog.lsonline.fr)**

> \[note\]Note  
>  
> The user account that will perform the following actions has to have sufficient permissions on the target sites collection and on the App Catalog.

### PowerShell (Windows only)

1. Download the **PowerShell solution** from the [repository](https://gitlab.lsonline.fr/SharePoint/sp-dev-fx-webparts/analytics/-/releases?ref=blog.lsonline.fr)

![](https://blog.lsonline.fr/content/images/2021/01/Screenshot-2019-02-15-at-09.59.59.jpg)

1. Unzip the package
2. From your *PowerShell terminal*, connect to your target site collection with [Connect-PnPOnline](https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/connect-pnponline?ref=blog.lsonline.fr) cmdlet  
```PowerShell  
Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/target-site  
```
3. Launch the `setup.ps1`  
```PowerShell  
.\setup.ps1 -siteUrl https://contoso.sharepoint.com/sites/target-site -trackingID 'UA-000000000-1'  
```

> \[note\]**Note**  
>  
> If you can't execute the PowerShell script, cause of security reason, before unzip the package, execute the [Unblock-File](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/unblock-file?view=powershell-6&ref=blog.lsonline.fr) cmdlet.

> \[note\]Note  
>  
> In this example, the package is deploy to the Site Collection App Catalog. You have other options like illustrated into the [README.md](https://gitlab.lsonline.fr/SharePoint/sp-dev-fx-webparts/analytics/blob/master/README.md?ref=blog.lsonline.fr), that allow you to manage the deployment.

### Any platform (Linux, Mac OS, Windows)

1. Download **any platform** solution from the [repository](https://gitlab.lsonline.fr/SharePoint/sp-dev-fx-webparts/analytics/-/releases?ref=blog.lsonline.fr)

![](https://blog.lsonline.fr/content/images/2021/01/Screenshot-2019-02-15-at-10.00.42.jpg)

1. Unzip the package
2. Allow `setup.sh` script execution  
```bash  
chmod +x ./setup.sh  
```
3. From your *Bash terminal*, connect to your target site collection with [spo login](https://pnp.github.io/office365-cli/cmd/spo/login/?ref=blog.lsonline.fr) cmdlet  
```bash  
spo login https://contoso.sharepoint.com/sites/target-site  
```
4. Launch the `setup.sh`  
```bash  
./setup.sh --siteUrl https://contoso.sharepoint.com/sites/target-site --    trackingID 'UA-000000000-1'  
```

> \[note\]**Note**  
>  
> In this example, the package is deploy to the Site Collection App Catalog. You have other options like illustrated into the [README.md](https://gitlab.lsonline.fr/SharePoint/sp-dev-fx-webparts/analytics/blob/master/README.md?ref=blog.lsonline.fr), that allow you to manage the deployment

Pretty simple, isn't it?

---

You will find below some additional information about the Google Analytics interface and its configuration (thank you Karen for your suggestion 🙏)

[Ultimate Beginner’s Guide to Google Analytics 4 (NEW 2020 Interface)If you’ve ever taken a quick peek at Google Analytics, you were probably thinking to yourself, “What is going on here? Where do I even begin?”![](https://dt2sdf0db8zob.cloudfront.net/wp-content/themes/websiteplanet/img/favicons/android-icon-192x192.png?v=1)Website PlanetWebsite Planet![](https://dt2sdf0db8zob.cloudfront.net/wp-content/uploads/2019/04/Beginners-Guide-to-Google-Analytics-850x435.jpg)](https://www.websiteplanet.com/blog/ultimate-beginners-guide-google-analytics/?ref=blog.lsonline.fr)

Enjoy 🚀🥳
  
  
Hoping this post will help you 🚀