Google analytics 谷歌分析电子商务跟踪片段
我试图跟踪电子商务交易使用谷歌分析电子商务跟踪Google analytics 谷歌分析电子商务跟踪片段,google-analytics,e-commerce,Google Analytics,E Commerce,我试图跟踪电子商务交易使用谷歌分析电子商务跟踪 <?php $tx_token = '234234234'; $amount = '19.99'; ?> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-12345678-1']); _gaq.push(['_trackPageview']); _gaq.push(['_addTran
<?php
$tx_token = '234234234';
$amount = '19.99';
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345678-1']);
_gaq.push(['_trackPageview']);
_gaq.push(['_addTrans',
'<?php echo $tx_token; ?>', // Transaction ID
'My Store', // Affiliation or store name
'<?php echo $amount; ?>', // Total
]);
_gaq.push(['_addItem',
'D1D44',
'My Item',
'Category / Variation',
'<?php echo $amount; ?>',
'1'
]);
_gaq.push(['_trackTrans']);
(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>
var _gaq=_gaq | |[];
_gaq.push([''设置帐户','UA-12345678-1']);
_gaq.push([''u trackPageview']);
_gaq.push(['''u addTrans',
'',//事务ID
'我的店铺',//隶属关系或店铺名称
'',//总计
]);
_gaq.push(附加项),
“D1D44”,
“我的物品”,
“类别/变化”,
'',
'1'
]);
_gaq.push([''u trackTrans']);
(功能(){
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);
})();
这够了吗?我是否需要addItem和addTrans中的$tx\u令牌值?是的,您需要事务中每个项目的事务id(这就是Google Analytics可以判断这些项目属于某个事务的方式)。因此,事务id是每个addItem调用所需的第一个参数。实际上,GA文档()中对这一点进行了详细的描述