I am looking for the exact same answer to your question here. I want to place this same code on my “thank you” page similar to what you have. I located the variables from my third party shopping cart an inserted them based on the instructions provided by google here https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingEcommerce. I also added some addition code for in case multiple products are added to the cart. I’m just not sure if this is correct or not. Did you get your question answered? Might you be able to provide me with some additional guidance and let me know if this looks correct to you.
<script type=“text/javascript”>
var _gaq = _gaq || ;
_gaq.push([‘_setAccount’, ‘UA-XXXXX-X’]);
_gaq.push([‘_trackPageview’]);
_gaq.push([‘_addTrans’,
‘unique_order_id’, // unique order ID - added by gabe, provided by premium web cart
‘order_id’, // order ID - required
‘billing_name’, // customer billing name - added by gabe, provided by premium web cart
‘billing_company_name’, // affiliation or store name
‘product_total’, // product total - added by gabe, provided by premium web cart
‘order_total’, // order total - required
‘’, // tax
‘’, // shipping
‘billing_customer_city’, // city
‘billing_customer_state’, // state or province
‘billing_country’ // country
‘billing_customer_zip’ // zip
]);
// add item might be called for every item in the shopping cart
// where your ecommerce engine loops through each item in the cart and
// prints out _addItem for each
_gaq.push([‘_addItem’,
‘unique_order_id’, // unique order ID - added by gabe, provided by premium web cart
‘order_id’, // order ID - required
‘product_1_sku’, // SKU/code - required
‘product_1_name’, // product name
‘product_1_price’, // unit price - required
‘product_1_quantity’, // quantity - required
‘product_2_sku’, // SKU/code - required
‘product_2_name’, // product name
‘product_2_price’, // unit price - required
‘product_2_quantity’, // quantity - required
‘product_3_sku’, // SKU/code - required
‘product_3_name’, // product name
‘product_3_price’, // unit price - required
‘product_3_quantity’, // quantity - required
‘product_4_sku’, // SKU/code - required
‘product_4_name’, // product name
‘product_4_price’, // unit price - required
‘product_4_quantity’, // quantity - required
‘product_5_sku’, // SKU/code - required
‘product_5_name’, // product name
‘product_5_price’, // unit price - required
‘product_5_quantity’, // quantity - required
‘product_6_sku’, // SKU/code - required
‘product_6_name’, // product name
‘product_6_price’, // unit price - required
‘product_6_quantity’, // quantity - required
]);
_gaq.push([‘_trackTrans’]); //submits transaction to the Analytics servers
(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
// add item might be called for every item in the shopping cart
// where your ecommerce engine loops through each item in the cart and
// prints out _addItem for each
_gaq.push([‘_addItem’,
‘unique_order_id’, // unique order ID - added by gabe, provided by pwc
‘order_id’, // order ID - required
‘product_1_sku’, // SKU/code - required
‘product_1_name’, // product name
‘product_1_price’, // unit price - required
‘product_1_quantity1’ // quantity - required
]);
_gaq.push([‘_trackTrans’]); //submits transaction to the Analytics servers
(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
As for the link that goes from the “add to cart” button on my website, I haven’t installed this yet. I’m still trying to understand the code syntax. I found one site that explains this. http://www.jensbits.com/2010/02/01/google-analytics-third-party-shopping-cart-cross-domain-tracking-using-traditional-and-asynchronous-snippet/ It looks a little different than how you have it where you start with ([‘_link’, So I dont’ know if this is where you might be experiencing issues. Please let me know if you have worked out a solution for this as well.
The other wrinkle I am having is that I use wordpress for all of my site content. And I have a plugin for Google Analytics provided by Yoast http://yoast.com/wordpress/ This is a great plugin and it seems to be installing the basic asynchronous analytics code on every page so I don’t have to do this manually. But it doesn’t seem to install the ecommerce tracking code. Unfortunately I am not getting any support from Yoast except through the WordPress Forum; which isn’t very helpful.
My trouble is I don’t know whether the analytics code above needs to be inserted on every page or if I can just include it on my “Thank You” page? I was thinking that could leave the basic asynchronous analytics code provided by the Yoast plugin on every page and then apply this separate code for ecommerce tracking just to my “Thank You” page. Do you have any idea whether this would work or do I need to replace the basic asynchronous analytics code provided by the Yoast plugin on every page?
Thank you in advance for any assistance you may be able to provide.