Sunday, December 8, 2024
HomeMicrosoft 365How to Add Google Analytics Tracking Code to SharePoint Online to Monitor...

How to Add Google Analytics Tracking Code to SharePoint Online to Monitor Website Traffic and Metrics?

use Google Analytics in SharePoint Online, you need to add the Google Analytics tracking code to your SharePoint site. Here are the steps to do this:

  1. Sign up for a Google Analytics account and create a new property for your SharePoint site.

  2. Once you have created the property, you will be provided with a tracking ID. Copy the tracking ID as you will need it in the next step.

  3. In SharePoint Online, go to Site Settings and select the option for “Design Manager”.

  4. From the Design Manager, choose “Edit Master Pages”.

  5. Select the master page you want to edit, and choose “Edit File” from the dropdown menu.

  6. In the code editor, add the Google Analytics tracking code just before the closing </head> tag.

Here is an example of what the tracking code should look like:

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

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


Most Popular