程序是Ecshop,订单的提交页面地址栏有个step参数值为done,下面的代码是在提交页面向GA加入订单和购买的产品列表,GA后台已经能看到了,但是不知道怎么知道这笔订单的来路。因为SEO是跟别人合作的,需要区分SEO的订单和其他广告产生的订单。希望有做过这个的大大能帮帮忙。
分割线var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-xxxxxx-2']); //账户ID _gaq.push(['_setDomainName', 'none']); _gaq.push(['_setAllowLinker', true]); _gaq.push(['_trackPageview']); /***GA***/ <!-- {if $step eq "done"} 订单提交成功--> _gaq.push(['_addTrans', "<!--{$order.order_sn}-->", // Order ID "<!--{$order.parent_id}-->", // Affiliation "<!--{$order.goods_amount}-->", // Total "0", // Tax "<!--{$order.shipping_fee}-->", // Shipping "<!--{$order.city}|{$order.district}-->", // City "<!--{$order.province}-->", // State "<!--{$order.country}-->" // Country ]); <!--{foreach from=$goods_list item=goods}--> _gaq.push(['_addItem', "<!--{$order.order_sn}-->", // Order ID "<!--{$goods.goods_sn}-->", // SKU "<!--{$goods.goods_name}-->", // Product Name "<!--{$goods.goods_id}-->", // Category "<!--{$goods.goods_price}-->", // Price "<!--{$goods.goods_number}-->" // Quantity ]); <!--{/foreach}--> _gaq.push(['_trackTrans']); <!-- {/if} --> (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); })();