Everything you need to know about Google Analytics 4 integration with Modern SharePoint.

Google Analytics data collection is useful for in-depth insight into public-facing sites and can help companies gain insight into their intranet usage. Right now, there is a bit of a scramble to get up to date on Google Analytics 4 (GA4) migration, given that the standard Universal Analytics properties will stop processing data on July 1, 2023. This blog post will show you how to add GA4 snippet to your Microsoft 365 SharePoint intranet.

Add GA4 to your SharePoint intranet

Let’s start with a few basics. For you to get GA4 usage data across your intranet, you will need to add the gtag.js snippet to every page of your SharePoint site collection. But this is no easy task with SharePoint out of the box. Fortunately, there’s a no-code solution within each BindTuning theme.

BindTuning themes: More than just cosmetic

More than just a brand center for colors and fonts, BindTuning themes are in use by thousands of companies who face structural limitations to their SharePoint-based intranets. As developers, we built our themes to address some of these seemingly basic needs that were just too difficult to do with SharePoint out of the box.

Giving Modern SharePoint back some of the features Classic SharePoint offered, each BindTuning theme allows you to copy/paste custom CSS or scripts (such as the GA4 snippet) right in the settings panel. The input field can be maximized, giving you the entire real estate of your screen while coding. Scripts load synchronously, one after the other.

This powerful capability provides webmaster controls of the UX and it is where GA4 can easily be added to any SharePoint site. BindTuning themes are just one feature included in each BindTuning Intranet subscription.

Where to find the GA4 (gtag.js) measurement id?

In order to add the GA4 snippet you first need to have a measurement id, that is associated with your Web Data Stream. Click here to learn how to create a Data Stream.

Assuming you have your Data Stream created, now follow these steps:

  1. Click on the Admin navigation
  2. At the top of the Property column, select your property
  3. In the Property column, click Data streams > Web
  4. Select your Data Stream
  5. Under Stream details, save the MEASUREMENT ID value
Note: To learn more about switching from analytics.js to gtag.js, visit this page.

I have the GA4 measurement id, now what?

Now that you have your code, let’s add it to your site using a BindTuning theme.

  1. Go to BindTuning.com and click on Design > Themes Gallery
  2. Pick a theme
  3. Brand this theme
  4. Install it
spfx-theme

Now that the theme is installed, you can add the custom script using the settings panel

  1. Open your SharePoint site collection
  2. On the ribbon, select the button BindTuning Settings
  3. Navigate to the Advanced Tab
  4. From there, you are able to paste the following code in the Custom Script section. Make sure to replace the two {MEASUREMENT ID} tokens with the value you saved previously
.var gtag = setInterval(function() { 
if(!document.getElementById('track-gtag')) { var script = document.createElement('script'); script.id = 'track-gtag'; script.src = 'https://www.googletagmanager.com/gtag/js?id= {MEASUREMENT ID}'; document.head.appendChild(script); clearInterval(gtag); setTimeout(function() { window.dataLayer = window.dataLayer || []; function gtag(){ dataLayer.push(arguments); } gtag('js', new Date()); gtag('config', '{MEASUREMENT ID}'); }, 1000) } }, 50);

That’s it. Now your intranet will be ready for GA4!

BindTuning Intranet – easy-to-use, no-code themes

Easy-to-use, no-code themes are just one feature of a BindTuning Intranet. A digital workplace that allows employees to perform at their best starts with a modern sleek design that allows users to organize and display content in engaging, inclusive ways. Site owners, content creators, and administrators alike will love the easy-to-configure and flexible tools bundled in one BindTuning Intranet offering:

Our team is standing by to help answer any questions you may have, or to give you a quick demo.

Get a demo