Tuesday, December 28, 2010

Google Analytics on SharePoint

Seeing the title we might feel that what is the big deal in using Google Analytics on SharePoint content management sites, yes we can get the page views by just embedding few lines of code provided by Google Analytics site.

In the Current implementation we went with a different approach for providing flexibility to Content Authors to manage the Custom Variables, Events and so on...

At a high level following image shows you the flow:

At a high level we used following components in SharePoint which are the inputs to Google Analytics APIs

1. Custom Site Columns

There a set of site columns created for the publishing pages. Few of them are grouped with the group name called "MetaTagGroup". All the columns which are part of this group will be converted to Metatags.

We used a delegate control in SharePoint for generating these meta tags. For more info you can refer to the article on Meta tag generator

Following image shows the set of custom Site Columns mapped to MetaTagGroup

Now the content author has a flexibility to define the values for these Site Columns or Publishing page attribute which inturn converted Meta Tags and then passed to Google Analytics variables as explained in the next step.

2. Additional javascript layer on Google Analytics APIs

An additional javascript functions are created to call respective Google Analytics APIs. And also this javascript contains an array to map Meta tag name with the GA variables, Scope and their slots as shown below:

var arrGAVariables = [
{'GAVariable':'Segment-Type', 'MetaTagName':'Segment-Type', 'Scope':3, 'Slot':3},
{'GAVariable':'Target-Audience', 'MetaTagName':'Target-Audience', 'Scope':1, 'Slot':1},
{'GAVariable':'Business-Technology', 'MetaTagName':'Business-Technology', 'Scope':3, 'Slot':4}

Please feel free to contact me to get more insights on this implementation.

1 comment:

Bill Richardson said...

What do you mean by "additional javascript functions used to call Google API"? Can you post your additional javascript functions, with focus on where the array is used?