Home » News & Blog  

Archive for October, 2009

How to Integrate NetSuite with Google Analytics

Thursday, October 8th, 2009

We recently announced that we found a workaround to integrate Google Analytics with NetSuite and it’s available as one of our services. We decided to share this information with everyone and tell you how it’s done.

If you have no scripting skills we can do this for you, just contact us.

Although this is a pretty small script, it achieves something pretty important, so we decided to release it under the LGPL license which means you can use it or adapt it to your needs, improve it and distribute it freely across the web as long as you don’t remove the copyright notice.

Basically Google Analytics is not able to track all the data (keyword, referrer and everything else) because it changes the domain name. Although it’s a pretty simple approach, it does a lot.

Our aproach to this is pretty unique in two ways:

  1. It uses a hidden iframe and pageTracker._getLinkerURL() while Google recommends using a regular link and a pageTracker._link() to make the eCommerce tracking work. This is pretty important because it makes the code so much smaller than having to parse all the links and forms on the site.
  2. Instead of linking to the checkout page like Google suggests in their documentation, in the case of NetSuite, the checkout page does an unnecessary refresh we decided it’s better to just have a blank html page that you can send the cookies to.

In our example we are on the domain www.roomitup.com and we have some cookies stored by Google Analytics, but visible only within that domain.

We need to find a way to transfer all those cookies into checkout.netsuite.com

In your page, after the Google Analytics code, write the following lines:

//***********************************************************************************
// Copyright 2009 Citricle. All rights reserved.
// This script is released under the LGPL license which means you can use it or adapt it
// to your needs, improve it and distribute it freely across the web as long as you don’t remove
// this copyright notice. For technical support go to www.citricle.com.
//***********************************************************************************

var domain = “roomitup.com”; //replace this with your own domain name
try    {
if(document.URL.indexOf(domain) != -1) {
if((document.referrer.indexOf(domain) == -1)  && (document.referrer != “”))    {
var iframeElement = document.createElement(”iframe”);
var proxyAddress = “https://checkout.netsuite.com/c.664770/citricle-ga.html”; //replace 664770 with your own NetSuite Account ID
iframeElement.setAttribute(”src”, pageTracker._getLinkerUrl(proxyAddress));
document.getElementById(”div__header”).appendChild(iframeElement);
iframeElement.style.display = “none”;
}
}
}
catch(e) {};

This will create a hidden iframe inside your website’s header (id is div__header) that will load the ga-tracker.html page, and it will pass the cookies using a query string generated by pageTracker._getLinkerURL(). That query string will contain those cookies that Google Analytics needs to track the keyword, referrer and everything else. Simple but useful huh?

The next step is to create what we call a proxy. It’s a blank html page that contains nothing more but your regular Google Analytics Code. Call it citricle-ga.html and upload it into your “Live Hosting Files” folder. The trick is that this file is hosted on the checkout.netsuite.com domain, which will allow Google Analytics to parse the cookies from the query string.

Why don’t we use the <NLCHECKOUTURL> ? Pretty simple. After going to the checkout page, NetSuite does a page refresh and reloads without the query string generated by Google Analytics. The first time it loads it (with the query string) it sends out the Location headers before Google’s Analytics script load and that was the main reason why this was so hard to achieve before.

Here’s the code for the citricle-ga.html:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Citricle Google Analytics NetSuite Proxy</title>
</head>

<body>
<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”>
var pageTracker = _gat._getTracker(”UA-1579697-1″); //replace UA-1579697-1 with your own account #
pageTracker._setDomainName(”none”);
pageTracker._setAllowLinker(true);
pageTracker._initData();
pageTracker._trackPageview();
</script>
<p>This solution was developed by <a href=”http://www.citricle.com”>Citricle</a>.</p>
</body>
</html>

This is pretty much our unique way of crossing the two domains. After that it’s only a matter of tracking the order on the checkout page. It’s nothing complicated, it was done before and there’s nothing unique about it. It’s just about following Google’s Documentation here.

If you still have any questions, contact us.

Integrating Google Analytics Order Tracking with NetSuite

Saturday, October 3rd, 2009

Using Google Analytics with NetSuite will work just fine. It will track all the metrics and keywords you need.

However most people are spending a lot of money on pay per click advertising such as  Google AdWords, Yahoo, Bing and other type of campaigns. They would like to see how much money they spent on a certain keyword and how much revenue it generated. That’s a good way to determine if the keyword is worth the price.

Google Analytics supports e-commerce tracking, but with the way NetSuite handles the data you just can’t do it. And people are looking for a solution to that.

The good news is that we have the solution, we tested it and it works perfectly. It’s also open source, so you can use it for free (as long as you keep the copyright notice), or hire us to do it for you at a very decent pricing if your scripting skills aren’t that good.

Citricle’s NetSuite/Google Analytics integration solution will track orders and their amounts, items (with price, quantity), keywords (organic or pay-per-click), referrer and everything else Google Analytics supports (such as how much revenue a specific keyword generated).

Now, you can invest only in the keywords that drive revenue and a favorable ROI.

Here’s how the left menu with this option will look like:

For more information go here.