This solution provides a way to easily implement Google Analytics tracking on your SharePoint Sites.

Instructions

For Google Analytics a specialized clientside javascript has to be injected into the page. Upon request of this page, the script will activate and log the page requests to the servers of Google Analytics. It's advised that the script is placed just before the closing of the body tag.

For injecting the clientside javascript a servercontrol is provided: "Macaw.Wss4.GoogleAnalyticsSolution.GoogleAnalyticsTrackingCode.GoogleAnalyticsTrackingCodeControl". This servercontrol is best to be placed onto the Masterpages of your site, but can also be placed on the PageLayouts. There are multiple ways to do this:

Configuration

There are multiple ways of configuring the Tracking.

The default tracking settings can/will be overridden by the settings which are done via the GoogleAnalyticsSolution UserInterface.

The GoogleAnalyticsTrackingCodeControl has the following properties:

TrackerCode
The default TrackerCode which will be used inside the Tracking Script
TrackAuthenticated
The default setting wether the pages requested by authenticated users should be tracked
TrackEditMode
The default setting wether the edit mode should be tracked

The configuration set via the GoogleAnalyticsSolution UserInterface will get stored as CustomProperties on SPFile and SPFolder . It's important to be aware that these settings get exported and also deployed via ContentDeployment.

Upon activation of the Configuration Feature three links will be provided to manage the settings:

All links are context-aware. This means that when one clicks on the "Manage Google Analytics"-link of the PageAction, you will define the settings for that page (SPFile). The "Manage Google Analytics"-link of the Library-group will modify the specific library (SPFolder).

Please be aware that it might be neccesary to flush your browser-cache to set the links in the Ribbon. 

 




 

As of SP2010 it would be technically possible to create Pages in SubFolders of the Pages-folder. Although not tested, this solution would be compatible with this.

Notes:

Unfortunatly it was not possible to provide this solution as a Sandboxed Solution as no SafeControl-entry would be registered and the DelegateControl would not load.This is bydesign, see: microsoft.sharepoint.webcontrols.delegatecontrol
Also it's not possible to use an ascx in sandboxed solutions.