PANVEGA’s Blog

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:

ga1

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 http://www.mydomain.com you would enter http://www.mydomain.com/pages/default.aspx. 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:  http://domain.com to  http://domain.com/pages/default.aspx.
  • 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”);
pageTracker._setDomainName(“none”);
pageTracker._initData();
pageTracker._trackPageview();
}
</script>

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:

http://weblogs.asp.net/wesleybakker/archive/2009/01/15/sharepoint-google-analytics-feature.aspx

Advertisements

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. http://www.mapilab.com/sharepoint/statistics/ Integration with Active Directory, deeply detailed reports, reports on search, support of any topology.
    MAPILa

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

 
%d bloggers like this: