Tuesday, May 26, 2009

Netsuite and Google Analytics How To - Part 2

Assuming you followed the steps in part 1 and have your Google Analytics code - let's plug that into Netsuite so you can start tracking your pages, clicks and sources and soon to be charted associated revenue.
Add the GA code to all of your site (most of it at least)
Let's go back to this screen shot from Part 1 and fill in section (1).
You should have a block of code that looks like this from when you registered for GA (with your code in the xxxxxxx-x area and missing the two lines in red that we are going to add):

<script type="text/javascript">
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"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-xxxxxxx-x");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
} catch(err) {}
</script>

The code in red is what tells GA to allow your-domain.com to pass the information along when we hop over to the netsuite.com domain for checkout.
Now - take that modified block of code and put it in section (1). When you press save - you have just added GA tracking to every page that's hosted from the store and managed via the Content Manager interface... You will need to manually add that code snippet somewhere on any of the html pages or forms you may also have hosted inside Netsuite. (A trick to this is to make a custom tag - put the code in the tag - and then just add the custom tag to the content... so if you ever need to change this it's only in one place).

Add the "magic code" for the cross domain hop
This single step right here is the real meat of Netsuite 2009.1 - it's this simple step that makes this work... whereas prior to 2009.1 you either had to hand code this or find a provider to do this part for you. Past the following code into section (3).:
onSubmit="javascript:pageTracker._linkByPost(this);"
That's it - SAVE away.

Enable e-Commerce in Google Analytics
This is an easy one to miss - and the simplest component of this second post- you need to log into Google Analytics, go to Analytics Settings>Profile Settings>Edit Profile Information - and select "Yes, an E-Commerce Site

If you never come back here - you will have nearly 100% working integration with these simple steps.

Up next post - the magic code that is "missing" to add the revenue reporting on checkout. I will make it as simple as cut and paste (sorta).