How to add Google tag manager globally to SharePoint Online
A solution to add google tag manager has being requested a few times to me since I released the solutions to add Google Analytics to SharePoint.
In this article you will find a pre-built solution to add Google tag manager to modern SharePoint Online using an Application Customizer.
What is Google Tag Manager?
How to Setup Google Tag Manager
First things first, before we get into the SharePoint bits let’s set up google tag manager and get everything you need.
- Sign in to your Tag Manager account
- Create a Workspace for your SharePoint site
- From the top bar copy the Tracking ID as shown in the picture below
How to add Google Tag Manager to modern SharePoint
To get the solution provided in this article globally deployed follow the steps below:
- Download and Extract the solution from here
- Open your tenant app catalog
- Click on Apps for SharePoint
- Upload the solution to the catalog
- Check the option Make this solution available to all sites in the organization
- Go to Site Contents
- Open the list Tenant Wide Extensions
- Edit the Gtagmanager item
- Modify the Component Properties and replace the trackingID value by your Google Tag Manager tracking ID.
- Save the item and all your modern SharePoint sites on Office 365 will get Google Tag Manager. If this was the first solution globally deployed on your tenant, it may take up to 20 minutes get available.
As always the source code of this solution is available on GitHub