How To Enable Google Analytics In Sharepoint Online

Enabling Google Analytics within SharePoint Online can offer valuable insights into the utilization and effectiveness of your SharePoint site. As an avid SharePoint user, I have found this capability to be extremely beneficial in comprehending how visitors engage with my site and pinpointing areas for enhancement. In this guide, I will walk you through the steps of implementing Google Analytics in SharePoint Online.

Step 1: Sign up for Google Analytics

The first step is to sign up for a Google Analytics account if you don’t already have one. Simply visit the Google Analytics website and follow the registration process. Once you have your account set up, proceed to the next step.

Step 2: Get your Google Analytics Tracking ID

After signing up, you will be given a unique tracking ID for your Google Analytics account. This ID is essential for integrating Google Analytics with your SharePoint Online site. To retrieve your tracking ID, navigate to the Admin section of your Google Analytics account and select the specific property or website for which you want to enable tracking.

Under the Property column, you will find the Tracking Info option. Click on it, and then select Tracking Code. The tracking ID will be displayed at the top of the page, in a format similar to “UA-XXXXXXXX-X”. Copy this tracking ID to your clipboard, as you will need it in the next step.

Step 3: Access SharePoint Online settings

Now, log in to your SharePoint Online site with administrative privileges. Navigate to the Site Settings page, which can usually be accessed by clicking on the gear icon in the top-right corner and selecting “Site Settings” from the drop-down menu.

Step 4: Enable custom script

In SharePoint Online, custom script capabilities are disabled by default for security reasons. To enable custom script, go to the Site Settings page and under the “Site Collection Administration” section, click on “Site collection features”. Find the feature named “SharePoint Server Publishing Infrastructure” and activate it. This step is necessary to allow the inclusion of the Google Analytics tracking code in your SharePoint site.

Step 5: Add Google Analytics tracking code

Once custom script capabilities are enabled, you can proceed to add the Google Analytics tracking code to your SharePoint Online site. To do this, go back to the Site Settings page and under the “Site Collection Administration” section, click on “Master pages and page layouts”. Here, select “Master pages”. Open the master page that you are using for your site (usually named “default.master”) using a text editor or SharePoint Designer.

Locate the closing tag in the master page HTML code. Just before this tag, insert the following code:

<!-- Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'YOUR_TRACKING_ID');
</script>

Replace “YOUR_TRACKING_ID” with the actual tracking ID you obtained in Step 2. Save the master page and exit the text editor or SharePoint Designer.

Step 6: Verify Google Analytics integration

To verify that Google Analytics is now enabled in your SharePoint Online site, log in to your Google Analytics account and navigate to the “Realtime” section. Open your SharePoint site in a different browser tab or window and perform some actions on the site, such as navigating to different pages or submitting forms. You should see real-time data in your Google Analytics dashboard, confirming that the integration is working correctly.

Conclusion

Enabling Google Analytics in SharePoint Online can provide you with valuable insights into the usage and performance of your site. By following the step-by-step process outlined in this article, you can easily integrate Google Analytics into your SharePoint Online site. Analyzing the data collected by Google Analytics will allow you to make informed decisions and optimize your SharePoint site for a better user experience.