Tracking Vists on another website

WhatsMySize.com is a Clothes Size Calculator which recommends great clothes based on your actually body measurements.  This month I want to track my visitor journey on third party websites to establish how well WhatsMySize.com is doing in finding the right clothes  for our users.

WhatsMySize.com uses Google Analytics and after a heck of a lot of surfing (hence this post) I found an article on the Google Analytics website that might help. To test the article I created a basic html page on another completely different domain (KSLConsultants.com).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
 <title>My Page Title</title>
</head>
<body>
  hello...
</body>
</html>

Step 1

Step 1 of the google article isn’t clear, but assuming you have already implemented Google Analytics on your main website and it’s working, simply copy this same tracking code and paste it between the <head> tags on the external page you wish to track.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
 <title>My Page Title</title>
 <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-xxxxxx-x");
  pageTracker._setDomainName("none");
  pageTracker._setAllowLinker(true); 
  pageTracker._trackPageview();
 </script>
</head>
<body>
  hello...
</body>
</html>

Step 2

Simply ask add a few tracking parameters to your normal link to the third party site. So mine is as follows ;

<a href=” http://www.kslconsultants.com/checkouttest/index.html” onclick=”pageTracker._link(this.href); return false;”>Testing Link</a>

But lets face it my nice visitors on whatsmysize are going to wander around the third party website so just link through the page that makes sense on that site and when they get to the page that needs tracking google will work it out.

<a href=" http://www.kslconsultants.com/" onclick="pageTracker._link(this.href); return false;">Testing Link</a>

Step 3

Finally we want to track what money has been spent on the third party site. So lets use the addTrans function as found in the api.

<div>
<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-7680084-1");
pageTracker._trackPageview();
pageTracker._addTrans(
"[order ID]", // order ID - required
"[reference name]", // affiliation or store name
"[order total price]", // total - required
"[vat]", // vat
"[shipping cost]", // shipping
"[customer city]", // city
"[customer state or shire]", // state or province
"[customer country]" // country
);
// the following add item ideally will be called for every item in the shopping cart
pageTracker._addItem(
"[order ID]", // order ID - necessary to associate item with transaction
"[SKU]", // SKU/code - required
"[product name]", // product name
"[description]", // category or variation
"[item price]", // unit price - required
"[quantity]" // quantity - required
);
pageTracker._trackTrans(); //submits transaction to the whatsmysize.com analytics servers
} catch(err) {}
</script>
</script></div>

Test it is working

Once done and a you have clicked through a few times we can check Google is tracking this new page. Open up your Google Analytics account and navigate through to  Top Content and you should see an entry for this page you are tracking. You may have to wait a while (in my case two hours) before Google updates itself.

entry in google analytics

ref

http://www.roirevolution.com/blog/2009/05/stressing_about_your_ga_ecommerce.html

One Reply to “Tracking Vists on another website”

Comments are closed.