rxz99 / analytics-issues

Automatically exported from code.google.com/p/analytics-issues
0 stars 0 forks source link

Google Analytics - ECommerce Tracking - Whether it will work for HTML4 or HTML5 #594

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I am developing Google Analytics - ECommerce Tracking in my site. I want to 
know if it works for HTML4 or HTML5. My site had limitation that it takes code 
for only HTML4 and not HTML5.

Please confirm.

Thank you.

Regards
Rohan Sarker
CEO & Founder
SwitchGate CrystalShift - www.rohansarker.com
+913324288069

Original issue reported on code.google.com by c...@rohansarker.com on 19 Mar 2015 at 12:47

GoogleCodeExporter commented 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:

GoogleCodeExporter commented 8 years ago
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