piwik的电子商务
1.piwik的自定义变量:
通过电子商务功能,可以统计通过各种入口进入网站的客户,最终流向目标url的次数
但是我们还需要更加复杂的统计,譬如对所有的产品页面进行统计,对所有的分类页面进行统计,这样,我们需要使用piwik的自定义变量
原理,piwik的统计代码如下:
通过上面的js收集当前页面的信息发送到piwik中,如果想添加自定义变量可以添加
setCustomVariable为固定函数名
1 代表 第几个变量
Gener 代表自定义变量的变量名
Male 代表自定义变量对应的值
Visit 代表范围,这个地方除了visit,还有一个值为page,关于对于这两个变量的说明:
when scope = "visit", the custom variable's name and value will be stored in the visit in the database. You can therefore store up to 5 custom variables of scope "visit" for each visit.
when scope = "page", the custom variable's name and value will be stored for the page view being tracked. You can therefore store up to 5 custom variables of scope "page" for each page view.
更详细的信息参看:
http://developer.piwik.org/api-reference/tracking-javascript#custom-variables
http://piwik.org/docs/custom-variables/
对于统计代码,思维定势是只能放到相应的网站中,但是我发现,放到其他的页面照样可以统计到,譬如在邮件里面嵌入统计代码,是可以统计到的
这样,我们可以用自定义变量做什么?
1.对于网站的某些类别的统计,譬如所有的产品页面,分类页面,论坛页面,博客页面等某类页面,在程序中都是一个文件通过程序计算出来的,我们可以统计这类url。
2.思维抛开统计的网站,抛到外面去,我们可以统计我们的一些外部资源
譬如:1.我们在一个博客主哪里打了一个广告,但是我们不知道我们的广告被展现了多少次,因此我们需要用这种方式,来统计这个广告被展现了多少次。
3.思维延伸--财务,二次开发,传递订单号等信息,然后批量处理脚本,通过api传递订单信息,就会吧整个流程打通。
1.piwik的自定义变量:
通过电子商务功能,可以统计通过各种入口进入网站的客户,最终流向目标url的次数
但是我们还需要更加复杂的统计,譬如对所有的产品页面进行统计,对所有的分类页面进行统计,这样,我们需要使用piwik的自定义变量
原理,piwik的统计代码如下:
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
// _paq.push(['trackPageView']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://piwik.tomtop.com/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 2]);
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>
<noscript><p><img src="http://piwik.tomtop.com/piwik.php?idsite=2" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
通过上面的js收集当前页面的信息发送到piwik中,如果想添加自定义变量可以添加
_paq.push(['setCustomVariable',1,"Gender","Male","visit"]);
然后在自定义变量就可以统计到:
官方的图片例子
代码
setCustomVariable为固定函数名
1 代表 第几个变量
Gener 代表自定义变量的变量名
Male 代表自定义变量对应的值
Visit 代表范围,这个地方除了visit,还有一个值为page,关于对于这两个变量的说明:
when scope = "visit", the custom variable's name and value will be stored in the visit in the database. You can therefore store up to 5 custom variables of scope "visit" for each visit.
when scope = "page", the custom variable's name and value will be stored for the page view being tracked. You can therefore store up to 5 custom variables of scope "page" for each page view.
_paq.push(['setCustomVariable',
// Index, the number from 1 to 5 where this custom variable name is stored
1,
// Name, the name of the variable, for example: Gender, VisitorType
"Gender",
// Value, for example: "Male", "Female" or "new", "engaged", "customer"
"Male",
// Scope of the custom variable, "visit" means the custom variable applies to the current visit
"visit"
]);
更详细的信息参看:
http://developer.piwik.org/api-reference/tracking-javascript#custom-variables
http://piwik.org/docs/custom-variables/
对于统计代码,思维定势是只能放到相应的网站中,但是我发现,放到其他的页面照样可以统计到,譬如在邮件里面嵌入统计代码,是可以统计到的
这样,我们可以用自定义变量做什么?
1.对于网站的某些类别的统计,譬如所有的产品页面,分类页面,论坛页面,博客页面等某类页面,在程序中都是一个文件通过程序计算出来的,我们可以统计这类url。
2.思维抛开统计的网站,抛到外面去,我们可以统计我们的一些外部资源
譬如:1.我们在一个博客主哪里打了一个广告,但是我们不知道我们的广告被展现了多少次,因此我们需要用这种方式,来统计这个广告被展现了多少次。
我们发出去的邮件,被多少个客户点击打开,就可以查看到。
当然对于很强的营销统计:(下面和自定义变量无关)
3.思维延伸--财务,二次开发,传递订单号等信息,然后批量处理脚本,通过api传递订单信息,就会吧整个流程打通。
注意:
当吧代码嵌入外部资源的时候,这个访问也是会被piwik统计到网站流量当中,所以,最后用另外一个账户:
可以看到,这个变量的统计,虽然嵌入到第三方资源中,但是还是会被统计,认为是网站自己的一部分流量,所以,解决这个问题,需要在piwik后台重新开一个网站账户,用这个账户单独统计网站的外部资源访问次数。