// Off-site Click Tracker
// by: Steve Kurtz, http://www.sewellinternet.com
// 
// Description:
// Tracks off-site clicks using Google Analytics Events and through E-Commerce
//
// Called with:
// <a href="http://www.off-site-link.com" onClick="clickTrack('Affiliation', 'Category', 'SKU', Value)">Test Link</a>
//
// NOTES:
//
// Event tracking only allows Integer values.
// Value should not be in quotes.
// Set UACode below to your specific Google Analytics Tracking Code

function clickTrack(Affiliation, Category, SKU, Value) {

// Set this variable to your Google Tracking Code
var UACode = "UA-238127-4";

// No need to change below here

// Derive a Transaction ID from the current Date/Time
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var seconds = currentTime.getSeconds();
if (day < 10) { day = "0" + day } ;
if (month < 10) { month = "0" + month } ;
if (hours < 10) { hours = "0" + hours } ;
if (minutes < 10) { minutes = "0" + minutes } ;
if (seconds < 10) { seconds = "0" + seconds } ;
var NewOrderID = " " + year + month + day + ":" + hours + ":" + minutes + ":" + seconds ;
NewOrderID = NewOrderID.substring(1,30);

try {
      // Track click as an E-Commerce Sale
	  pageTracker._addTrans(
		NewOrderID,            // Order ID
		Affiliation,           // Affiliation
		Value,                 // Total
		'0.0',                 // tax
      	'0.00',                // shipping
      	'N/A',                 // city
      	'N/A',                 // state or province
      	'N/A'                  // country
	  );
	  pageTracker._addItem(
	    NewOrderID,            // Order ID
	    SKU,                   // SKU
	    SKU,                  // Product Name 
		Category,              // Category
	    Value,                 // Price
	    1                      // Quantity
	  );  
	  pageTracker._trackTrans();
	  
      // Track click as an Event
      pageTracker._trackEvent(Affiliation, Category, SKU, parseInt(Value));
	  
	} catch(err) {}
	
// Now add Adwords Conversion Tracking
// Code exerpted from Adwords, Reporting -> Conversions
// Just get the image
var image = new Image(1,1);
image.src = "http://www.googleadservices.com/pagead/conversion/1067947106/?value=" + Value +"&amp;label=ktoeCIC9ngEQ4qie_QM&amp;guid=ON&amp;script=0";

}
