ECShop安装Piwik脚本进行跟踪功能测试

发表于:2015-2-12 11:05

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:sxw2008    来源:51Testing软件测试网采编

  3、产品目录页跟踪
  在/ecshop/themes/default/category.dwt末尾加入如下脚本
<script type="text/javascript">
var tags=document.getElementById("ur_here").getElementsByTagName("a");
var category_name='';
if(window.navigator.userAgent.toLowerCase().indexOf("firefox")!=-1){
category_name=tags[tags.length-1].textContent;
} else{
category_name=tags[tags.length-1].innerText;
}
var _paq = _paq || [];
(function(){ var u=(("https:" == document.location.protocol) ? "https://xxxxx:8080/tracking/" : "http://xxxxxx:8080/tracking/");
_paq.push(['setSiteId', "X0000001"]);
_paq.push(['setTrackerUrl', u+'js']);
_paq.push(['enableLinkTracking']);
//_paq.push(['trackEcommerceOrder',"C10000123", 35,30,5.5,4.5,false]);
_paq.push(['setEcommerceView',productSku=false,productName =false,category=category_name]);//_paq.push(['setEcommerceView',false,false,category_name]);
_paq.push(['trackPageView']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js';
s.parentNode.insertBefore(g,s); })();
</script>
  4、产品页跟踪
  在加入/ecshop/themes/default/goods.dwt
<script type="text/javascript">
var goods_sn="{$goods.goods_sn}";
var goods_name="{$goods.goods_style_name}";
var goods_price="{$goods.shop_price_formated}".replace("¥","").replace("元","");
var tags=document.getElementById("ur_here").getElementsByTagName("a");
var categorys=[];
for(var i=0;i<tags.length;i++)
{
if(window.navigator.userAgent.toLowerCase().indexOf("firefox")!=-1){
categorys[i]=tags[i].textContent;
} else{
categorys[i]=tags[i].innerText;
}
}
var _paq = _paq || [];
(function(){ var u=(("https:" == document.location.protocol) ? "https://xxxxx:8080/tracking/" : "http://xxxxx:8080/tracking/");
_paq.push(['setSiteId', "X0000001"]);
_paq.push(['setTrackerUrl', u+'js']);
_paq.push(['enableLinkTracking']);
_paq.push(['setEcommerceView',goods_sn,goods_name,categorys,goods_price]);
_paq.push(['trackPageView']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js';
s.parentNode.insertBefore(g,s); })();
</script>
  5、购物车,订单详情和订单完成跟踪
  在/ecshop/themes/default/flow.dwt末尾加入
<script type="text/javascript">
var goods_list="{$goods_list}";
var _paq = _paq || [];
var total=0;
if("{$step}"=="cart")//购物车
{
{foreach from=$goods_list item=goods}//遍历产品列表
_paq.push(['addEcommerceItem',
"{$goods.goods_id}", // (required) SKU: Product unique identifier
"{$goods.goods_name}", // (optional) Product name
false, // (optional) Product category, string or array of up to 5 categories
"{$goods.goods_price}".replace("¥","").replace("元",""),
"{$goods.goods_number}" // (optional, default to 1) Product quantity
]);
total+="{$goods.goods_price}".replace("¥","").replace("元","")*"{$goods.goods_number}";
// Records the cart for this visit
{/foreach}
_paq.push(['trackEcommerceCartUpdate',total]);
}
else if("{$step}"=="checkout")//订单明细
{
{foreach from=$goods_list item=goods}
_paq.push(['addEcommerceItem',
"{$goods.goods_id}", // (required) SKU: Product unique identifier
"{$goods.goods_name}", // (optional) Product name
false, // (optional) Product category, string or array of up to 5 categories
"{$goods.goods_price}".replace("¥","").replace("元",""),
"{$goods.goods_number}" // (optional, default to 1) Product quantity
]);
{/foreach}
}
else if("{$step}"=="done")//下单完成
{
_paq.push(['trackEcommerceOrder',
"{$order.order_sn}", // (required) Unique Order ID
"{$total.amount_formated}".replace("¥","").replace("元",""), // (required) Order Revenue grand total (includes tax, shipping, and subtracted discount)
false, // (optional) Order sub total (excludes shipping)
false, // (optional) Tax amount
false, // (optional) Shipping amount
false // (optional) Discount offered (set to false for unspecified parameter)
]);
}
(function(){ var u=(("https:" == document.location.protocol) ? "https://xxxxx:8080/tracking/" : "http://xxxxx:8080/tracking/");
_paq.push(['setSiteId', "X0000001"]);
_paq.push(['setTrackerUrl', u+'js']);
_paq.push(['enableLinkTracking']);
_paq.push(['trackPageView']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript'; g.defer=true; g.async=true; g.src=u+'piwik.js';
s.parentNode.insertBefore(g,s); })();
</script>
22/2<12
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号