Hello,
I was wondering if someone can guide me in inserting google analytics into my Business Catalyst website. Here is the generic code from Google Analytics website:
<html>
<head>
<title>Receipt for your clothing purchase from Acme Clothing</title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans',
'{tag_orderid}', // order ID - required
'Acme Clothing', // affiliation or store name
'{tag_amount}', // total - required
'1.29', // tax
'5', // shipping
'San Jose', // city
'California', // state or province
'USA' // country
]);
// 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',
'1234', // order ID - required
'DD44', // SKU/code - required
'T-Shirt', // product name
'Green Medium', // category or variation
'11.99', // unit price - required
'1' // 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>
</head>
<body>
Thank you for your order. You will receive an email containing all your order details.
</body>
</html>
I understand I need to replace the company information with tags and in the above code I have done this for {tag_orderid} and {tag_amount} then added this code to the receipt - Buy Module Template Layout. It is now tracking the amount of the transaction, but of course the productname and other variables aren't there.
How do I do this and can I add additional tags in the Receipt - Buy module layout? If so, what are the tags; if not, where and how do I insert the relevant code.
Any help greatly appreciated.
Cheers Fenwick
Hi Fenwick,
Currently BC doesn't have the actual product purchase information available at this stage in the transaction (Receipt Page), as the product purchase information is only available in the Shopping Cart Summary page. And you can't use the {webform_results} with this module.
I've never managed to get the actual product details with the few quick test I've done like spanning the google transaction across the pages from the data generated at the summary page using cross-domain tracking.
One alternative option is to use cookies to store the order information at the shopping cart summary page and then re-use them at the receipt page. It's a lot of extra work as you'll need to update the cookies if they make changes to their order and only commit if their order is successful, but will just depend on how much you want the data to show up in GA and how accurate you want the data to be.
Another (just as bad for other reasons) option is to put the code on the shopping cart page and tinker with some custom order ID's.
Either way you'll need to run JS. Kiyuco have a good tutorial in setting this up.
It's on the wishlist.
I think it's this one http://kiyuco.com/tutorials/never-lose-your-google-analytics-session-a t-checkout-again
Actually, I know you can set up GA conversions in BC, but to my knowledge, you cannot easily configure to have e-commerce data passed in. There was a long thread on this in the old forums. Mario - the link you pasted is a good one but just allows GA to accurately measure visitors from the basic domain to the worldsecuresystesm.com domain.
I followed those GA topics on the old forums and there were 3 long threads on them, but no one actually posted a code that I could share with everyone. It was all "i thinks" and "maybes". You practically have to tie in a function call to the checkout button and the first time I've seen someone actually do it is those kiyuco guys.
-mario
There was this KB article though: http://kb.worldsecuresystems.com/235/bc_2355.html
The following code example illustrates how to add the tags to the Google tracking code:
pageTracker._addTrans(
"{ tag_orderid}", // Order ID
"", // Affiliation
"{ tag_amount}", // Total
"", // Tax
"", // Shipping
"", // City
"", // State
"" // Country );
Yes. I wrote a post here: How to set up Google Analytics Ecommerce Tracking for BC
North America
Europe, Middle East and Africa
Asia Pacific