Open GoogleCodeExporter opened 8 years ago
Please let me know if the following HTML Code will work for Google Analytics -
ecommerce:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Thank you for your order</title>
</head>
<body>
<p>Thank you for your order. Your details have been sent to
customer@email.com.</p>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-60740482-1']);
_gaq.push(['_trackPageview']);
// transaction details
_gaq.push(['_addTrans',
'1234',
'SitePoint',
'109.99',
'10.00',
'0.00',
'Chicago',
'Illinois',
'USA'
]);
// item 1
_gaq.push(['_addItem',
'1234',
'css123',
'CSS Live',
'Online Course',
'9.99',
'1'
]);
// item 2
_gaq.push(['_addItem',
'1234',
'cb999',
'Donation for Craig's excellent blog post',
'Well-deserved bonus!',
'100',
'1'
]);
// track transaction
_gaq.push(['_trackTrans']);
// load Analytics
(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>
</body>
</html>
Original comment by c...@rohansarker.com
on 21 Mar 2015 at 3:01
Attachments:
Please let me know if the following HTML4 Code will work for Google Analytics -
ecommerce:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>My first Google Analytics ECommerce Project</TITLE>
</HEAD>
<BODY>
<!-- Google Analytics Script for www.rohansarker.com -->
<SCRIPT>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-Y', 'auto');
ga(‘set’, ‘&uid’, {{USER_ID}});
ga('send', 'pageview');
ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id': '1234', // Transaction ID. Required.
'affiliation': 'SwitchGate CrystalShift - www.rohansarker.com', // Affiliation or store name.
'revenue': '0.02', // Grand Total.
'shipping': '0', // Shipping.
'tax': '0' // Tax.
});
ga('ecommerce:addItem', {
'id': '1234', // Transaction ID. Required.
'name': 'Modern Poster', // Product name. Required.
'sku': 'PK115856', // SKU/code.
'category': 'Picture', // Category or variation.
'price': '0.02', // Unit price.
'quantity': '1' // Quantity.
});
ga('ecommerce:send');
</SCRIPT>
<!--Google Analytics Ecommerce Plugin Loading added on 17 March 2015. Google
Analytics Tracking Data working from 17 March 2015 -->
<!-- End Google Analytics Script added for SwitchGate CrystalShift on 14 March
2015 -->
</BODY>
</HTML>
Original comment by c...@rohansarker.com
on 21 Mar 2015 at 3:04
Original issue reported on code.google.com by
c...@rohansarker.com
on 19 Mar 2015 at 12:47