Google Analytics logo

Using Google Analytics with SharePoint

This post describes why it’s beneficial to use a user analytics tool in your intranet. I use Google Analytics as an example of such tool, and different deployment options for SharePoint intranets are covered briefly.

Why would I use Google Analytics with my SharePoint intranet?

In general, it’s absolutely necessary for you to know your users, if you want to deliver an enjoyable user experience. One key aspect of knowing them is knowing what they do, while they use your system or service. SharePoint being a web-based software, it’s quite logical to use one of the many user analytics suites available for web sites to also analyze your intranet users.

So I should analyze my users?

Generally, I’m going to say yes. But there are a few reasons, why you might not want to use Google Analytics for that. Here’s an extremely short, “executive summary” list of pros and cons of Google Analytics used in SharePoint.


  • Easy to install
  • Same tool can be used for all of your brand websites and most other services, so the data is in the same place
  • Offers a level customization in regards to what is tracked and how it’s reported
  • Basic features are easy to use – you get a simple report out quickly and easily
  • It’s free!
  • A lot of partners are available, so you won’t easily get vendor-locked (apart from Google, of course..)
  • A lot of help and documentation is available
  • Google Analytics is SaaS with a reliable track record (= good availability)
  • Requires very little ongoing maintenance efforts (apart from deciphering the data it records)


  • Difficult to recognize certain users (no integration to AD for example)
  • Can’t save data on your own servers – it’ll all be on Google’s servers
  • Get-parameters are saved on the aforementioned servers, so you may exist some data leakage!
  • It’s possible for the users to block the tracking, and there isn’t much you can do about it
  • Document analytics not easily available (you’ll have to use SharePoint’s or OneDrive’s usage reports for that)
  • Not integrated to O365 in any way – reports are in a different silo, or delivered via email
  • Measures usage slightly differently than O365, so reports from 2 different sources don’t match


All in all, even though there are other options, Google Analytics is one perfectly valid option for the user analytics tool for your intranet. 

How to use Google Analytics in SharePoint?

There are a couple of different implementations, each with pros and cons. I’ll go through the most useful ones very quickly. If you’ve done any SharePoint development ever, the headlines probably say something to you, but just to make this clear: they describe the technique which could be used to install the tracking code on to the site. Under that there’ll be pros (first, in green) and cons (in red) below that.

Tracking code in the master page

+ Pros:

  • Injected everywhere, where the master page is used with just one change.

– Cons:

  • You’ll have to edit master page, which is not recommended

Tracking code injected as a script link

+ Pros:

  • Very non-pervasive
  • Very easy deployment, directly from the browser as a custom JavaScript-file
  • Google Analytics script is located in its own file, so it’s not confusing
  • Customizable – want to add url parameters that forbid tracking? Or add custom data to GA? All doable!

– Cons:

  • If any of your use cases results in new site collections being published, the injection needs to be done to them as well
  • Unless you customize the injected script, you’ll be following system page loads as well

Tracking code in the publishing page layouts

+ Pros:

  • Doesn’t require editing master page

– Cons:

  • Only usable on publishing pages
  • As editing out-of-the-box publishing page layouts is not recommended, you’ll have the tracking available only on custom layouts

Tracking code in your other custom JavaScript files

+ Pros:

  • Consistent – whatever way you maintain and deploy your other JavaScript, you’ll maintain the tracking code as well. Simple and straightforward!
  • Customizable – want to add url parameters that forbid tracking? Or add custom data to GA? All doable!

– Cons:

  • The tracking script is in the same file as some other functionalities, which can be a little confusing

What else?

There are probably other options, too, but these were the ones that quickly came to mind, and most of which we’ve been using in different projects.

The following two tabs change content below.

Antti K. Koskela

Solutions Architect / Escalations Engineer at Koskila / Norppandalotti Software / Valo Solutions
Antti Koskela is a proud digital native nomadic millenial full stack developer (is that enough funny buzzwords? That's definitely enough funny buzzwords!), who works as a Solutions Architect for Valo Intranet, the product that will make you fall in love with your intranet. Working with the global partner network, he's responsible for the success of Valo deployments happening all around the world. He's been a developer from 2004 (starting with PHP and Java), and he's been bending and twisting SharePoint into different shapes since MOSS. Nowadays he's not only working on SharePoint, but also on .NET projects, Azure, Office 365 and a lot of other stuff. This is his personal professional (e.g. professional, but definitely personal) blog.

Let me know your thoughts!