谷歌分析电子商务跟踪修改



考虑在封闭源电子商务平台上运行的网站上添加Google Analytics电子商务跟踪。Google在他们的帮助系统中给了我们下面的代码作为例子:

<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>

这只是放在最后的销售页面上,还是我需要对数据做任何事情?不确定,因为从来没有这样做过,该网站是运行在php/mysql脚本。

要实现GA电子商务跟踪,您需要知道您的购物车变量名称(orderTotal, orderArray等-每个购物车平台不同)以及如何在呈现感谢页面时将它们插入脚本中,以便客户的订单具有正确的详细信息。

通常,您将插入所有addTrans变量,然后对addItem执行循环(对购物车中的每个项目执行一次循环)。但是,这个的细节真的取决于你的购物车,所以我不能比这更具体。

根据您的购物车社区的大小/精明程度,您可以找到一个预先准备好的示例,您可以将其放到您的感谢页面模板中,或者甚至可以将其作为一个模块内置。

最新更新