欢迎各位兄弟 发布技术文章
这里的技术是共享的
piwik
Piwik 是一套基于 Php+MySQL 技术构建,能够与 Google Analytics 相媲美的开源网站访问统计系统。Piwik 可以给你详细的统计信息,比如网页浏览人数, 访问最多的页面, 搜索引擎关键词等等,并且采用了大量的AJAX/Flash技术,使得在操作上更加便易。
Piwik 可以安装在你的服务器上面,数据就保存在你自己的服务器上 面。你可以非常容易的插入统计图表到你的博客或是网站后台的控制面板中。安装完成后,你只需将一小段代码放到将要统计的网页中即可。
此外,它还采用了插件扩展及开放API架构,拥有众多不同功能的插件,也可以让开发人员根据自己的实际需求创建更多的功能。
PHP + Apache 配置安装 Window下配置PHP环境
直接下载PHP集成安装环境 wampserver
如果是电子商务网站可以开启电子商务网站分析配置
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//piwik.maxtp.cn/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 1]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//piwik.maxtp.cn/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
_paq.push(['setDocumentTitle', document.domain + "/" + document.title]);
_paq.push(['trackPageView']);
trackEvent(category, action, [name], [value])
_paq.push(['trackEvent', 'Documentary', 'Rating', 'Thrive', 9.5]);
<a href="#" onclick="javascript:_paq.push(['trackEvent', 'Menu', 'Freedom']);">Freedom page</a>
setEcommerceView( productSKU, productName, categoryName, price )
产品
[...]
// all parameters are optional, but we recommend to set at minimum productSKU and productName
_paq.push(['setEcommerceView',
"9780786706211", // (required) SKU: Product unique identifier
"Endurance: Shackleton's Incredible Voyage", // (optional) Product name
"Adventure Books", // (optional) Product category, or array of up to 5 categories
20.11 // (optional) Product Price as displayed on the page
]);
_paq.push(['trackPageView']);
[...]
类别
[...]
// on a category page, productSKU and productName are not applicable and are set to false
_paq.push(['setEcommerceView',
productSku = false, // No product on Category page
productName = false, // No product on Category page
category = "Adventure Books" // Category Page, or array of up to 5 categories
]);
_paq.push(['trackPageView']);
[...]
addEcommerceItem(productSKU, productName, productCategory, price, quantity)
如果订单有多个产品需要循环调用 trackEcommerceOrder(orderId, grandTotal, subTotal, tax, shipping, discount)
[...]
// add the first product to the order
_paq.push(['addEcommerceItem',
"9780786706211", // (required) SKU: Product unique identifier
"Endurance: Shackleton's Incredible Voyage", // (optional) Product name
"Adventure Books", // (optional) Product category. You can also specify an array of up to 5 categories eg. ["Books", "New releases", "Biography"]
8.8, // (recommended) Product price
1 // (optional, default to 1) Product quantity
]);
// Here you can add other products in the order
[...]
// Specifiy the order details to Piwik server & sends the data to Piwik server
_paq.push(['trackEcommerceOrder',
"A10000123", // (required) Unique Order ID
35, // (required) Order Revenue grand total (includes tax, shipping, and subtracted discount)
30, // (optional) Order sub total (excludes shipping)
5.5, // (optional) Tax amount
4.5, // (optional) Shipping amount
false // (optional) Discount offered (set to false for unspecified parameter)
]);
// we recommend to leave the call to trackPageView() on the Order confirmation page
_paq.push(['trackPageView']);
[...]
TODO
TODO
setCustomVariable(index, name, value, scope = "visit")
_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"
]);
_paq.push(['trackPageView']);
setCustomVariable(index, name, value, scope = "page")
// Track 2 custom variables with the same name, but in different slots.
// You will then access the statistics about your articles' categories in the 'Visitors > custom variables' report
_paq.push(['setCustomVariable', 1, 'Category', 'Sports', 'page']);
// Track the same name but in a different Index
_paq.push(['setCustomVariable', 2, 'Category', 'Europe', 'page']);
// Here you could track other custom variables with scope "page" in Index 3, 4 or 5
// The order is important: first setCustomVariable is called and then trackPageView records the request
_paq.push(['trackPageView']);
_paq.push(['setUserId', 'USER_ID_HERE']);
_paq.push(['trackPageView']);
_paq.push(['setSiteId', 1]);
_paq.push(['setTrackerUrl', u+'piwik.php']);
// Same cookie as: example.com, www.example.com, subdomain.example.com, ...
_paq.push(['setCookieDomain', '*.example.com']);
_paq.push(['setDomains', '*.example.com']); // Download & Click tracking alias domains
_paq.push(['trackPageView']);
可以用于统计 某个品牌下产品的浏览数
TODO
http://developer.piwik.org/guides/tracking-api-clients
可以使用其他语言调用api添加对应的统计信息
java https://github.com/piwik/piwik-java-tracker
http://piwik.org/log-analytics/
导出对应的图片
通过后台导出对应格式的数据 获得APIURL
http://developer.piwik.org/guides/querying-the-reporting-api
直接生成对应的html代码 iframe
中国地图信息及城市坐标问题
性能优化
个性插件
数据量的时候需要关闭实时统计需要根据定时器统计
http://piwik.org/
http://developer.piwik.org/
http://piwik.org/docs/
http://demo.piwik.org/
http://www.piwik.cn/
百度文库
优化设置
piwik_demo
来自 https://www.zybuluo.com/dzhai/note/214710