有多种方式可从电子商务引擎检索此类信息。有些电子商务引擎会将购买信息写入您可以使用的隐藏表单,有些电子商务引擎则会将信息保存在您可以检索的数据库中,而有些电子商务引擎则会将这些信息存储在 Cookie 中。某些认可 Google Analytics(分析)的更为热门的电子商务引擎会提供自己的模块以便简化 Google Analytics(分析)的订单跟踪过程。
price 和 total 参数的值不遵循任何货币格式。 对于这两个参数,英文逗号或英文句点的第一个实例都表示小数值。例如,如果您提供 1,996.00 作为 total 参数的值,则系统会将其记录为 1.996,而不是 $1,996.00。由于该值不与任何币种相关联,因此您的电子商务软件必须先处理所有货币换算,然后才能将数据传递到 Google Analytics(分析)。
<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', '1234', // transaction ID - required 'Acme Clothing', // affiliation or store name '11.99', // 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', // transaction 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>
传统语法
<html>
<head>
<title>Receipt for your clothing purchase from Acme Clothing</title>
</head>
<body>
Thank you for your order. You will receive an email containing all your order details.
<script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol ) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script> <script type="text/javascript"> try{ var pageTracker = _gat._getTracker("UA-xxxxx-x");
pageTracker._trackPageview(); pageTracker._addTrans( "1234", // transaction ID - required "Womens Apparel", // affiliation or store name "11.99", // total - required "1.29", // tax "15.00", // 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 pageTracker._addItem( "1234", // transaction ID - necessary to associate item with transaction "DD44", // SKU/code - required "T-Shirt", // product name "Olive Medium", // category or variation "11.99", // unit price - required "1" // quantity - required );
pageTracker._trackTrans(); //submits transaction to the Analytics servers } catch(err) {} </script>
</body>
</html>