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).

15 comments:

  1. I'm anxiously awaiting Part 3. I already had Parts 1 & 2 done/working. It's Part 3 where I'm stuck (as are, I'm sure 1000s of other people!)

    Can't wait.

    ReplyDelete
  2. Andy, I really appreciate what you've shared and am eager to see part 3!

    I do have a persistent problem, however, that your instructions do not address.

    When I add the submit script: onSubmit="javascript:pageTracker._linkByPost(this);"
    my Paypal button stops working. NS support suggests adding either
    return false;
    or
    return true; to the end of the script, but neither seems to make a difference. If I leave the submit script box blank, my Paypal button works again. Have you (or any of your other readers) encountered this?

    ReplyDelete
  3. Same problem here, once I add the submit script, neither my PayPal or Google Checkout buttons work anymore.

    ReplyDelete
  4. Hi Andy,

    When might we see part 3?

    Thanks,

    ReplyDelete
  5. Sorry all - I know Part 3 is the "clincher" - I have just been slammed at work.
    I PROMISE I'll get something up early next week.

    As for the checkout buttons breaking for PayPal and Google - it still fails if the added code is:
    onSubmit="javascript:pageTracker._linkByPost(this); return true;" ?

    ReplyDelete
  6. Ok, times up! Where's the clincher? :D

    Jk, but just wanted to check in and see if this was coming out soon, and if you've found a problem with your solution and the paypal/googleout bug.

    Thanks

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. All - I know the wait has been brutal... I do apologize - life in the "real world" has been very busy. And this post isn't Blogger friendly... but - rest assured - you will have something to work on over the upcoming weekend - I promise!

    ReplyDelete
  9. As for the Google Checkout / Paypal button - that's a Defect that's Open and Netsuite is working to resolve... for right now - you get one or the other... not both :(

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. Hey, when you make promies on your blog, you must follow through... ;)

    WHERE'S THE BEEF?!?

    ReplyDelete
  13. Later today - SWEAR TO THE LORDS OF THE WEB...

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. Damn - that's pressure :)

    Hope it's all you have been waiting for...

    And - you should only have to cancel about 30 minutes of your meetings... I hope!

    ReplyDelete