How To Add Google Analytics To The Modern Sharepoint

Integrating Google Analytics into your modern SharePoint site is an excellent method for monitoring and examining user engagement on your site. As a web developer, I have discovered Google Analytics to be an essential resource for understanding user actions and utilizing data to enhance the overall user experience. This article will provide a step-by-step guide on how to add Google Analytics to your modern SharePoint site.

Step 1: Sign up for Google Analytics

The first step is to sign up for a Google Analytics account if you don’t have one already. Simply visit the Google Analytics website and follow the instructions to create a new account. Once you have created your account, you will be provided with a unique tracking ID.

Step 2: Access SharePoint Settings

Next, navigate to your SharePoint site and click on the gear icon in the top right corner to access the settings menu. From the dropdown menu, select “Site settings” to open the site settings page.

Step 3: Add Google Analytics Tracking Code

In the site settings page, scroll down to the “Web Designer Galleries” section and click on “Master pages and page layouts”. This will open the master pages and page layouts gallery. Locate the master page file that you want to edit (usually named “seattle.master”) and click on it to open the file.

Once the master page file is open, find the <head> section of the code. This is where we will add the Google Analytics tracking code. Insert the following code snippet just before the closing </head> tag:

<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>

Make sure to replace “YOUR_TRACKING_ID” with the actual tracking ID you obtained from Google Analytics in Step 1.

Step 4: Save and Publish

After adding the tracking code, save the master page file and publish it. This will apply the changes to all pages on your SharePoint site. Keep in mind that modifying the master page file may require administrative privileges.

Step 5: Verify Tracking

To verify that Google Analytics is correctly tracking your SharePoint site, visit your site and navigate to a few different pages. Then, log in to your Google Analytics account and go to the “Real-Time” section. You should see live data showing the number of active users on your site.

Conclusion

By adding Google Analytics to your modern SharePoint site, you gain valuable insights into user behavior and can make data-driven decisions to improve the user experience. With the ability to track and analyze user activity, you can identify popular content, measure campaign effectiveness, and optimize your site for better engagement. Incorporating Google Analytics is a simple yet powerful way to enhance your SharePoint site.