0
我想在Opencart的跟蹤交易定義,但我得到這個消息:GAQ不Opencart的2.0
Uncaught ReferenceError: _gaq is not defined(anonymous function)
這是我想做的跟蹤我
catalog/view/theme/default/template/common/success.tpl`
<!--THIS IS THE START OF THE TRACKING MOD-->
<?php if($order_tracker){
echo "SUCESSO";
$tracking_info = '<script type="text/javascript">';
//ADD TOP LEVEL TRACKING INFO
$tracking_info .= "_gaq.push(['_addTrans', '" . $order_tracker['order_id'] . "', '" . $order_tracker['store_name'] . "', '" . $order_tracker['total'] . "', '" . $order_tracker['tax'] . "', '" . $order_tracker['shipping'] . "', '" . $order_tracker['city'] . "', '" . $order_tracker['state'] . "', '" . $order_tracker['country'] . "']);";
//ADD INFO FOR EACH PRODUCT
foreach($order_tracker['products'] as $product){
$tracking_info .= "_gaq.push(['_addItem', '" . $product['order_id'] . "', '" . $product['model'] . "', '" . $product['name'] . "', '', '" . $product['price'] . "', '" . $product['quantity'] . "']);";
}
//ADD THE CURRENCY OF THE TRANSACTION
$tracking_info .= "_gaq.push(['_set', 'currencyCode', '" . $order_tracker['currency'] . "']);";
$tracking_info .= '</script>';
print $tracking_info;
} ?>
<!--THIS IS THE END OF THE TRACKING MOD-->
這是它如何被解釋在Chrome控制檯
<!--THIS IS THE START OF THE TRACKING MOD-->
<script type="text/javascript">_gaq.push(['_addTrans', '17', 'Zelulares', '805.0000', '', '5.0000', 'Sao Paulo', 'São Paulo', 'Brazil']);_gaq.push(['_addItem', '17', 'Product 16', 'MacBook', '', '500.00', '1']);_gaq.push(['_addItem', '17', 'Product 14', 'iMac', '', '100.00', '3']);_gaq.push(['_set', 'currencyCode', 'USD']);</script> <!--THIS IS THE END OF THE TRACKING MOD-->
編輯:
這是我列入Opencart的管理員在analytics.js代碼:
<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-XXXXXXX-X', 'auto');
ga('send', 'pageview');
</script>
您是否包含[GA base code](https://developers.google.com/analytics/devguides/collection/gajs/#tracking-code-quickstart)?或者您是否可能使用[Universal Analytics](https://developers.google.com/analytics/devguides/collection/analyticsjs/#quickstart)(analytics.js),並且您的代碼仍使用舊樣式(ga.js) 。 – MisterPhilip