Jan 15, 2008
Updated: There is often a need for Google Analytics tracking between domains. Between your website, and a third party secure server that you are able to add code to, or maybe another secure server in your group of websites.There is new Google analytics code as at January 2008. Please see the tracking code for multiple domains on the Google website, and their full Google analytics documentation.
Some Extras to Add to the tracking javascript
The standard new tracking code is below. There are two lines that need to be added (in bold) to allow for tracking between domains.<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-12345-1");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
</script>
On the thank-you page, you need to then add the following code:
Per Google - tracking Ecommerce transactions
Begin with a call to _addTrans() to establish a transaction. _addTrans() takes the following arguments: Order ID,Affiliation, Total, Tax, Shipping, City, State, Country. For each item that the visitor purchases, call _addItem(). _addItem() takes the following arguments: Order ID, SKU or Code, Product Name, Category, Price, Quantity.
Here is a complete example:
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-12345-1");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._initData();
pageTracker._trackPageview();
pageTracker._addTrans(
"1234", // Order ID
"Mountain View", // Affiliation
"11.99", // Total
"1.29", // Tax
"5", // Shipping
"San Jose", // City
"California", // State
"USA" // Country
);
pageTracker._addItem(
"1234", // Order ID
"DD44", // SKU
"T-Shirt", // Product Name
"Green Medium", // Category
"11.99", // Price
"1" // Quantity
);
pageTracker._trackTrans();
</script>
And now for the main domain
Rather than:change to:
per Google -
http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55532
If you are using a form to post to, have the following details:
- works for post and get forms
Get domain to show in Google Analytics reports
per Google - By default, the data in your reports will only include the Request URI and not the domain name. If you'd like to see the domain names in your reports, you can create an Advanced filter for your profile with the following settings:Filter Type : Custom filter > Advanced
Field A : Hostname Extract A : (.*)
Field B : Request URI
Extract B : (.*)
Output To : Request URI
Constructor : $A1$B1
Secure Server Code
Add this code to the thank-you page on https://www.seconddomain.co.nz following payment- I have used $70. Please change to the appropriate value.
You can also use it to track leads - set the google_conversion_label and label to "lead", or "signup" or "pageview". In fact, you can make up any label to assign the variable to. ie "newsletter".
<!--
var google_conversion_id = xxxxxxxx;
var google_conversion_language = "en_AU";
var google_conversion_format = "1";
var google_conversion_color = "666666";
if (70.0)
{
var google_conversion_value = 70.0;
}
var google_conversion_label = "purchase";
//-->
</script>
<script language="JavaScript" src="https://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<img height=1 width=1 border=0 src = "https://www.googleadservices.com/pagead/conversion/xxxxx/imp.gif?value=70.0&label=purchase&script=0">
</noscript>
Make sure you track every movement
Do you have ajax on your pages??? If so, are you tracking those "page requests" on your stats package? Google analytics has facility to track ajax requestsTrack Flash Events
Adding Tracking onto links
<a href="http://www.example.com" onClick="javascript: pageTracker._trackPageview('/outgoing/example.com');">
Air New Zealand Tickets
Book Air New Zealand Tickets and save on tickets on CheapOair,book today using CheapOair's exclusive travel coupon.
6 Comments
Thanks for your info, It is working fine with normal links . But I am having problem with form posting , Can you help on this?
Thank you
Thanks for sharing your knowledge.
I'm having an issue with using "return false", this stops the link been processed, any ideas?











Haiming - Search Engine Expert - Sep 23, 2008
Hi Michael,
Thank you so much for this article! It gives me the idea how to put the Google Adword tracking code in to onlineshop site. It seems like I should read all articles first before I ask you any question :)