DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

Using Google Analytics with SharePoint

Posted by PANVEGA on March 14, 2009

One of my clients wants to use Google Analytics (GA) for their SharePoint (MOSS 2007) intranet. GA is a web analytics package provided free by Google.  You sign up plug some JavaScript into your site (provided to you during the sign up process).

Thanks to the way SharePoint 2007 uses master pages, it’s a breeze to hook it up.  I’m using GA for multiple sites, some are SharePoint 2007 WCM sites and some are not.  As you know, SharePoint already has some built in usage analysis capabilities and they are pretty good.  GA extends these capibilities and provides a more common interface and set of tools for slicing your web site usage data.

There’s some good information out there about how to set this up, but I wanted to clarify a few points in the hope of saving others some time.

The basic steps are:

  1. Obtain the Fully Qualified Domain Name (FQDN) for your MOSS site.
  2. Create your Google Analytics account (see detail below). FYI, You don’t need to pass any authentication in order to track hits to your site.
  3. Add the GA tracking code to your site’s master page within the HTML Body tags, which will allow you to analyze all the sub-pages, not just the home page.
  4. If you doo not have the right permissions to change the masterpage just add a WebEditor Webpart into your ASPX page and copy the JS code into it. Make the Webpart invisiblefor users by setting the Crometype to none

With regard to step 2, when you set up your new account, you need to enter your FQDN in the URL field, and you need to enter it the way they specify:


You need to activate your new site after you paste the JavaScript into your master page.  To activate your new site, you need to provide the URL.  If you are using a publishing site (and you likely are if you are wanting to wire GA to it), then you need to provide the “/pages/default.aspx” part of your URL after the domain name.  For example; if your domain is you would enter This is because Google won’t like the fact that it’s getting redirected to /pages/default.aspx and will bail if you don’t provide that part.

Do the following steps to solve this ussue:

  • From the home page of your Google Analytics account, click Edit
  • Then, in the Profile Settings window, click Edit at the upper right
  • At this point you can change your website URL.  For the example I’m using, you would change: to
  • After 24 hours, you should be able to review results on your GA account page.

Another tricky think to know about GA with Moss URL:

If your SharePoint site is accessed via the hostname alone like http://mywebsite/ (ie. with no dots “.” in the domain name), you will want to add _setDomainName(“none”) to your tracking code so the cookies won’t be rejected by your employees browsers.

<script type=”text/javascript”>
if (typeof(_gat) == “object”) {
var pageTracker = _gat._getTracker(“UA-XXXXXX-1”);

I use Google Analytics to view trends on this blog and some other sites I control. It does a great job of showing trends and the most viewed pages.

More informations:


One Response to “Using Google Analytics with SharePoint”

  1. I can recommend you to try MAPILab Statistics for SharePoint for tracking advanced usage statistics of your SharePoint implementation. Integration with Active Directory, deeply detailed reports, reports on search, support of any topology.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: