Google Analytics logo

Using Google Analytics with SharePoint

This post was most recently updated on October 4th, 2022.

3 min read.

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 a 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 websites 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 the pros and cons of Google Analytics used in SharePoint.

Pros

  • Easy to install
  • The same tool can be used for all of your brand websites and most other services, so the data is in the same place
  • Offers 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 are 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)

Cons

  • 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 are 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 ever done any SharePoint development, 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 onto 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 the 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 the 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.

mm
4.7 3 votes
Article Rating
Subscribe
Notify of
guest

6 Comments
most voted
newest oldest
Inline Feedbacks
View all comments