@dzhai
2015-11-10T20:42:45.000000Z
字数 5042
阅读 2967
piwik
如果是电子商务网站可以开启电子商务网站分析配置
<!-- 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/
http://piwik.org/
http://developer.piwik.org/
http://piwik.org/docs/
http://demo.piwik.org/
http://www.piwik.cn/
百度文库
优化设置