How To Add Google Analytics To SharePoint

Learn how to add Google Analytics to SharePoint with our comprehensive step-by-step guide. To add Google Analytics to SharePoint, there are a few things to consider. Firstly, Google Analytics is not recommended for SharePoint as it may violate Google’s terms of service and compromise data privacy. However, if you still want to proceed, here’s a step-by-step guide:

  1. Sign up or sign in to Google Analytics at https://analytics.google.com.
  2. Click on the Admin cog on the dashboard and under the Admin Tab, click on ‘+ Create Account’.
  3. Fill in the required fields and uncheck all the boxes unless you want to share your corporate information with Google.
  4. Click ‘Get Tracking ID’ and copy the tracking code provided.
  5. To deploy Google Analytics to SharePoint, determine the version of SharePoint you are running.
  6. For SharePoint 2007, 2010, 2013, 2016, and 2019, use Visual Studio to create a SharePoint project and add a new item called “CustomAction” and a module called “Style Library”. Create a folder structure and add a JavaScript file with the tracking code.
  7. For SharePoint Online or SharePoint 2016/2019, use the SharePoint Framework to create an application customizer extension project. Edit the master page or use a declarative sandbox solution to add the tracking code.

Note that it is recommended not to use Google Analytics in SharePoint due to potential violations and lack of document tracking and site-specific group permissions in Google Analytics.

Step 1: Sign up or sign in to Google Analytics

The first step to adding Google Analytics to SharePoint is to sign up or sign in to your Google Analytics account. If you don’t have an account yet, you can create one by visiting the Google Analytics website at https://analytics.google.com. Once you’re on the website, click on the Admin cog on the dashboard, and under the Admin Tab, click on ‘+ Create Account’.

In the account creation form, fill in the required fields and uncheck all the boxes unless you want to share your corporate information with Google. After that, click ‘Get Tracking ID’. This will generate a unique tracking code that you’ll need to deploy Google Analytics to your SharePoint site.

Deployment methods for different versions of SharePoint

To deploy Google Analytics to SharePoint, you’ll need to determine the version of SharePoint you are running.

SharePoint Version Deployment Method
SharePoint 2007, 2010, 2013, 2016, 2019 Use Visual Studio to create a SharePoint project and add a new item called “CustomAction” and a module called “Style Library”. Create a folder structure and add a JavaScript file with the tracking code.
SharePoint Online or SharePoint 2016/2019 Use the SharePoint Framework to create an application customizer extension project. Edit the master page or use a declarative sandbox solution to add the tracking code.

It’s worth noting that using Google Analytics in SharePoint is not recommended due to potential violations of Google’s terms of service and the lack of document tracking and site-specific group permissions in Google Analytics. Consider these factors before proceeding with the deployment.

Step 2: Deploy Google Analytics to SharePoint

Once you have your Google Analytics account set up, the next step is to deploy it to your SharePoint site, following the appropriate method for your SharePoint version. It’s important to note that Google Analytics is not recommended for SharePoint due to potential violations of Google’s terms of service and limitations in tracking documents and site-specific permissions. However, if you still want to proceed, here’s a step-by-step guide:

For SharePoint 2007, 2010, 2013, 2016, and 2019:

To deploy Google Analytics to these versions of SharePoint, you will need to use Visual Studio to create a SharePoint project. Start by adding a new item called “CustomAction” and a module called “Style Library”. Create a folder structure within the module and add a JavaScript file with the tracking code.

This method allows you to customize the SharePoint site and include the Google Analytics tracking code within the JavaScript file. However, keep in mind that this method may not provide extensive tracking capabilities and may not be compatible with future updates to SharePoint.

For SharePoint Online or SharePoint 2016/2019:

If you are using SharePoint Online or SharePoint 2016/2019, it is recommended to use the SharePoint Framework (SPFx) to deploy Google Analytics. You can create an application customizer extension project within SPFx and edit the master page to include the tracking code.

Alternatively, you can also use a declarative sandbox solution to add the tracking code to your SharePoint site. This method allows for easier deployment without the need for custom development, but it may have limitations depending on your specific SharePoint configuration.

Remember, while it is possible to deploy Google Analytics to SharePoint, it is not the recommended approach due to potential violations and limitations in tracking and permissions. Consider exploring other analytics solutions that are specifically designed for SharePoint to ensure accurate and comprehensive data tracking.

Meet the Author

Abdul Rahim has been working in Information Technology for over two decades. Learn how Abdul got his start as a Tech Blogger , and why he decided to start this Software blog. If you want to send Abdul a quick message, then visit his contact page here.