Thursday, 26 November 2009

Google Analytic for Microsoft Office Live

I wondered how I can put tracking code of Google Analytic on a website designed on Microsoft Small Business Live. I found that I needed an xsl style file to embed inside my home page. I copied the tracking code offered by the Google Analytic. It is like this; it is java script:
&ltscript type="text/javascript"&gt
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt/script&gt
&ltscript type="text/javascript"&gt
try {
var pageTracker = _gat._getTracker("UA-XXXXXXXX-X");
pageTracker._trackPageview();
} catch(err) {}
&lt/script&gt
In the statement "UA-XXXXXXXX-X" the letter "X" stands for the numbers given by the Google Analytic profile for the desired website. Then I put this piece of code inside an xsl document like this
&ltxsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt
&ltxsl:output method="text" omit-xml-declaration="yes"/&gt
&ltxsl:template match="/"&gt
&lt![CDATA[
&ltscript type="text/javascript"&gt
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
&lt/script&gt
&ltscript type="text/javascript"&gt
try {
var pageTracker = _gat._getTracker("UA-XXXXXXXX-X");
pageTracker._trackPageview();
} catch(err) {}
&lt/script&gt

]]&gt
&lt/xsl:template&gt
&lt/xsl:stylesheet&gt
The Google Analytic codes are shown as boldface fonts inside the xls template. I put this in a notepad and saved it as, say, aStyle.xsl. The extension .xsl should not be forgotten and the file format is in UTF_8. Then I upload it to my "Documents Gallery" at my Microsoft Office Live website designing console.
Now I go to my "Page Manager" page in my Microsoft Office Live console and click on "Edit" for my home page. When the "Home Page" opens in "Edit" mode I notice two tabs. I select "Page Editor" tab. There, at the top from the "Insert" pane, I click on the second icon with a drop down menu; it is the "Insert Module" menu. I move the highlight down until I get to the "Custom footer." Upon selecting this, a dialogue opens. There is an option for "Link to an xslt file" and a "Select file" button. If you select this option then it takes you directly to the "Documents gallery" where you already had uploaded your file. You can point to the mentioned "aStyle.xsl" file. Looking at the zone that you have selected for the tracking "footer," then you can see a dashed border area. That does not show anything in your site. It is, merely, the Google tracking snippet resided there. Now go to your Google Analytic and follow their instructions. It immediately informs you of being successful in installing the tracker.

No comments:

Post a Comment