我正在嘗試向Google電子商務跟蹤提交數據,但它似乎沒有工作,我認爲這是因爲我不得不將代碼拆分開...Google電子商務跟蹤
這裏是我的代碼:
<html>
<head>
<title></title>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans',
'{{$id}}', // transaction ID - required
'{{$name}}', // affiliation or store name
'{{$amount}}' // total - required
]);
</script>
@foreach ($products as $product)
<script type="text/javascript">
_gaq.push(['_addItem',
'{{$id}}', // transaction ID - required
'{{$product['edg_code']}}', // SKU/code - required
'{{$product['product_name']}}', // product name
'{{$product['unit_price']}}', // unit price - required
'{{$product['quantity']}}' // quantity - required
]);
_gaq.push(['_trackTrans']); //submits transaction to the Analytics servers
</script>
@endforeach
<script type="text/javascript">
(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>
</body>
</html>
我缺少的東西或者是因爲我開拆腳本?
您可以詳細說明「它似乎沒有工作」嗎?你是否看到錯誤信息,你沒有看到數據在你的報告中填充,等等? – nyuen