Neil Thompson
asked on
trying to get javascript variables into Google Analytics code
Hi
I'm trying to get a few variables into a bit of Google Analytics code but not sure if I'm doing it right.
I want the var genOrderID I have assigned to be passed as the 1st param in addTrans and addItem, does the code below seem ok or should it be in '' 's if so wont it just be supplied as text?
Is there any way I can actually see the generated JS code, ive tried firefor generated source but it just shows as below?
Thanks
Neil
I'm trying to get a few variables into a bit of Google Analytics code but not sure if I'm doing it right.
I want the var genOrderID I have assigned to be passed as the 1st param in addTrans and addItem, does the code below seem ok or should it be in '' 's if so wont it just be supplied as text?
Is there any way I can actually see the generated JS code, ive tried firefor generated source but it just shows as below?
Thanks
Neil
<script type="text/javascript">
var genOrderID = new Date().getTime();
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345678-1']);
_gaq.push(['_trackPageview']);
_gaq.push([
'_addTrans', genOrderID, // order ID - required
'', // affiliation or store name
'100.00', // total - required
'', // tax
'', // shipping
'', // city
'', // state or province
'' // country
]);
_gaq.push([
'_addItem', genOrderID, // order ID - required
'CTX', // SKUcode - required
'Council Tax', // product name
'', // category or variation
'100.00', // 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>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Superb, many thanks
No idea on the Java stuff, sorry!
ASKER
:). I tried just adding what I put above and it worked instantly
ASKER
<bean:write name="payCTXForm" property="paymentResponse.