Reputation: 13
I'm trying to set up cross domain tracking using google analytics. Basically I have a widget which directs customers to a shopping basket where they can purchase an item.
We need to give the client some code to put on their receipt page but i am having trouble setting it up. I have set up a dummy project on two domains with the following code on our main page (which will be the widget when developed) that has the following code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-27715734-3']);
_gaq.push(['_setDomainName', 'myDomainA.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
(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>
<p>Direct to techport page <a href ="http://techport.e-talemarketing.co/Payment.html"onclick="_gaq.push(['_link', 'http://techport.e-talemarketing.co/Payment.html']); return false;"><input id="btnTechport" type="button" value="techport" /></a></p>
<p>Direct to forOffice page <a href ="http://foroffice.etailtesting.co.uk/Payment.html"onclick="_gaq.push(['_link', 'http://foroffice.etailtesting.co.uk/Payment.html']); return false;"><input id="btnForOffice" type="button" value="ForOffice" /></a></p>
and have put the following on the dummy receipt page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-27715734-3']);
_gaq.push(['_setDomainName', 'myDomainA.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
// 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',
'techport222', // order ID - required
'54321', // SKU/code - required
'Shiny jewels', // product name
'', // category or variation
'8', // unit price - required
'3'
]);
_gaq.push(['_trackTrans']); //confirms that a purchase has occurred and 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>
<p>
TechPort Payment receipt for item</p>
</body>
</html>
When setting up my account in Google Analytics i have made the default URL the main page url so www.MyDomainA.com.
And added 2 different shopping baskets.
I cannot see any events being tracked can anyone see what i am doing wrong?
I have set E-commerce tracking to true on both profiles aswel.
Edit: There is a strong possibility i was just being impatient as i can see events now - i just thought that the event section of google analytic s was meant to be real time...
Upvotes: 1
Views: 288
Reputation: 13115
How long have you given it? Sometimes it takes a few days to see events when they are fist setup. In your case, it looks like you are missing the _addTrans
method at the start of your ecommerce tracking.
_gaq.push(['_addTrans',
'1234', // order ID - required
'Womens Apparel', // affiliation or store name
'28.28', // total - required
'1.29', // tax
'15.00', // shipping
'San Jose', // city
'California', // state or province
'USA' // country
]);
...
_gaq.push(['_addItem',...
...
_gaq.push(['_trackTrans',...
Documentation here - http://code.google.com/apis/analytics/docs/gaJS/gaJSApiEcommerce.html#_gat.GA_Tracker_._addTrans
Upvotes: 1