如何开发 piwik 开发指南插件

展开微博窗口
微信:biaodianfu
展开分类目录
标点符(钱魏 Way)
是一套基于Php+MySQL技术构建,能够与相媲美的开源网站访问统计系统,前身是phpMyVisites。Piwik可以给你详细的统计信息,比如网页浏览人数, 访问最多的页面, 搜索引擎关键词等等,并且采用了大量的AJAX/Flash技术,使得在操作上更加便易。此外,它还采用了插件扩展及开放API架构,可以让开发人员根据自已的实际需求创建更多的功能。
Piwik的数据库结构图
上图(点击可查看大图)Piwik的数据库结构按照简洁、效率和模块化进行设计。其数据库包含以下部分
Statistics logger(统计记录)
Users & Permissions(用户和权限)
Site(网站)
Archived data(存档数据)
Debug / Info log(调试/信息记录)
SQL query profiling(SQL查询分析)
Statistics logger
统计记录部分包含统计到的用户访问日志,这些数据一些来自于Javascript的标记,一些包逊于Cookie,一些有PHP获取。每个单独的访问者在Cookie中标记了一个唯一的visitor_idcookie。在数据库表log_visit中记录了用户的每一次“visit”。例如一个访问者在一天内访问网站两次(中间相隔30分钟),log_visit中就会有两条该用户的记录。
在一次访问中,一个访问者至少会浏览一个页面,我们称每浏览一个页面为一个“action”,每个action都会被定义一个名称(”homepage”, “/blog/hello-world”)和类型(一个定义行为种类的整数)。所有的单独“action”都被储存在表log_action中。
每个用户新的action都被记录到表log_link_visit_action中,其中包含了idaction和idvisit。同时这个表还包含idaction_ref 和time_spent_ref_action 字段,用来记录用户的上一次action。当我们请求第二个页面,程序将从cookie中读取上一个页面的idaction ,并作为action_ref保存,并记录中间的时间time_spent_ref_action.使用这个技术是因为我们不需要去更新上一条记录的时间:我们只需要记录当前上层页面的信息。
Users & Permissions
一个用户被定义为login, password, email 和一个用于请求API的token_auth。对于一个网站一个用户会有不同的access级别(浏览、管理、没有权限或是超级管理员。
一个网站被定义为idsite和 main_url,main_url 是用来指向 site_url,所以它可以有很多的url。
Archived data
存档在piwik中是一段时间的数据聚合。它是由日志处理后得到的有具体含义的数据。
archive_* 表中的每行数据包含一个网站给定的日期/时间段的数据。例如,提条记录idsite = 3的这个网站在日的这周访问网站用户的国家列表。
Piwik的存档中总共有两种不同的数据类型的表:float和blob
archive_numeric_* 表是用来储存数值的。改字段值value使用的是FLOAT类型,即他可以保存整型和浮点数。比如储存给定时间点网站的访问者数。
archive_blob_* 表用来储存出数字以外的其他任何数据。BLOB是二进制数据类型,可以用来任何数据,比如字符串、字符串转化的序列数组、序列化的对象等。例如用来储存用户在一定时间段内所有的关键词。
事实上两个表都有相同的结构,除了value 字段的类型不同。他们同时包含以下字段:
idarchive 用来定义单独的存档。对于一个特殊的网站在一个特殊的时期内(特定的日期)会是相同的idarchive. 换句话说如果(idsite,period,date1,date2)相同,则idarchive 相同且为主键。
name 是用来记录值value 的描述。例如你想储存不同关键词的数量,比较恰当的name 可以是’Referers_distinctKeywords’
idsite 是记录所属的网站
date1 和 date2 使记录的起始日期和结束日期,如果记录的是一天的数据则date1 = date2.
period 用来定义周期的类型有: day / week / month / year.
ts_archived 是存档创建的时间戳。这个对确认存档是否还是有效很很大的帮助。比如今天的存档将会有效1小时或1分钟,这个取决于cache lifetime value的值。
value 包含name描述的数据
存档表里的每条记录都是由存档处理类进行自动处理的,其中存档处理有多个类:记录管理的是Piwik_ArchiveProcessing_Record_Manager,数值记录的Piwik_ArchiveProcessing_Record_Numeric,
blob记录的是Piwik_ArchiveProcessing_Record_Blob和字符串blob记录的Piwik_ArchiveProcessing_Record_Blob_Array。
存档的逻辑可以在Piwik_ArchiveProcessing类中找到,按日存档可以从Piwik_ArchiveProcessing_Day类中找到,按时间点的存档可以从Piwik_ArchiveProcessing_Period类中找到。需要注意的是大多数实时处理的存档都是通过插件来执行特殊的事件。
加载存档(或加载处理中的存档)是使用Piwik_Archive类完成的。
从性能上考虑,表按月划分。这就意味着每个月新标就会创建,所以数据会被有规律的划分。如果值使用一张表来储存所有数据,它将变的非常的巨大且查询起来非常的缓慢。数据表划分由Piwik_TablePartitioning类进行处理,按月划分的由Piwik_TablePartitioning_Monthly类完成。
我们使用不同的表结构(FLOAT 和 BLOB),因为它可以非常快速的查询整型/浮点数值。SQL查询会因为数据表非常的轻量(light)而非常的快(并且archive_numeric_* 的每行有固定的长度)。比如我们可以快速的查询最近30天的访客数。
Debug / Info log
表logger_error, logger_message, logger_api_call 和 logger_exception 是用来记录各种各样信息的。
logger_error 是用来记录错误信息。message 中包含line, php file errfile, backtrace。等。
logger_message 是用来记录所有的调试和系统信息的。
logger_api_call 是用来记录所有的API请求的。他会记录所有的请求参数(parameter_values)和返回的值(returned_value)、执行时间(execution_time)和请求地址的IP地址(caller_ip)等。这个信息又来使API请求更加的具体,当返回的值(returned_value)不正确的时候用于调试,监测API接口 的使用情况等。
logger_exception 是用来记录所有的异常的。
而整体的逻辑控制是由Piwik_Log来完成的。
SQL query profiling
表log_profiling是用来储存SQL查询的概要信息的。
注意:所有的时间戳都是由PHP生成的,而不是使用Mysql自带的NOW(), CURRENT_DATE()等函数。这是用来确保系统使用不同时间的服务器上的MySQL正常的运行。程序不是基于MySQL服务器的时间的。
未来的改进与优化
整个系统目前还存在很多性能改进的空间。比如,我们可以从以下几个方面进行改进。
按日期划分log_* 表(和archive_* 采用相同的处理方式)
审核大数据量下存档数据的SQL查询。
审核所有的索引策略。
为了避免大量的jions连接(log_visit, log_link_visit_action),我们可以通过复制(idsite, visit_server_date)字段使数据表非规范化。
如需了解更多的Piwik的原理和逻辑,请持续关注。
参考文章:
分享到: ()10个精选免费网站分析工具_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
10个精选免费网站分析工具
上传于||文档简介
&&介​绍​网​站​测​试​分​析​工​具​,​对​测​试​工​程​师​非​常​有​用
阅读已结束,如果下载本文需要使用3下载券
想免费下载本文?
下载文档到电脑,查找使用更方便
还剩3页未读,继续阅读
你可能喜欢& & 什么是Web分析学?web分析是指,收集站点对于访客的可用性以及有效性方面的有意义的信息,并对web内容的数据进行集合和分析的过程。Web分析相关的网络应用非常丰富,你也许已经知道类似 Google Analytics 和 Crazy Egg 的最有影响力的网站分析应用,以及类似 Alexa 和 Compete 等远程网站服务。& & 我们这里先跳过这些知名的应用并探讨一些不太知名的网络分析选项。在本文中,你将发现10个精选的免费web分析工具和应用程序,他们可以帮助你收集和分析与你网站内容有关的数据。1. Piwik& & & & 这里可以参考Piwik的在线演示& & Piwik是一个开放源代码的网站分析应用,它使用PHP和MySql开发。Piwik有一个允许你任意延伸和自定义的&插件&系统。你可以选择仅仅安装你需要的插 件,或者全部安装。Piwik插件系统,和你想象的一样,它也给你一个创建你自己的定制扩展应用的可能,并且piwik是个轻量级的应用,下载包只有 1.9MB。2. FireStats& & & & 参考 FireStats的在线演示.& & FireStats是一个简单和直接的网站分析应用,使用PHP和MySql开发。它支持多种平台,包括C#站点,Django站点,Drupal,Joomla等CMS,以及Wordpress和其他的一些平台。 你是一名经验丰富的开发人员吗?FireStats 还有一个 优秀的API[应用程序接口] ,它可以协助你创建你自己的基于你的FireStats数据的特制应用程序或发布平台组件 (想象看:在你的wordpress博客显示下载次数最多的10个文件) 。3. Snoop& & & & Snoop是一个基于桌面,运行在 Mac OS X 和 Windows XP/Vista 平台的web分析工具。它运行后,会驻留在你的系统状态栏或系统托盘中,当一些事件发生的时候,会有声音来提醒你。另外一个显著的Snoop特色就是Name Tags 选项,允许你使用&标记&来更容易的识别访客。因此,当在财务部门Joe的访问你的网站时,你会立刻知道。4. Yahoo! Web Analytics& & & & Yahoo!Webanalytics是在web分析行业占据主导地位的Google Analytics的另一个替代选择。它属于企业级的,健壮的,基于Web的第三方分析服务,特别是对于多用户集团,它更容易的实现数据的访问。yahoo网站分析工具全面提供你需要的web分析工具,比如图表工具,自定义设计(并且可打印)报表、以及实时数据跟踪。5. BBClone& & & & 参考BBClone的在线演示& & 如果你正在寻找一个简单的,服务端的并且不依赖于第三方服务的web应用来监控网站数据,BBClone- 一个基于PHP的服务端应用,为你报告详细的站点流量和访客数据。它支持32种本地化语言,包括英语,中文,德文,日文等。BBClone能够与时下最受 欢迎的发布平台容易的集成,比如Drupal,Wordpress,Textpattern等。 由于它是基于日志文件的,因此它不需要你使用其他的服务端关系数据库。6. Woopra& & & & Woopra是使用Java开发的web分析应用。它分为两个部分,包括一个桌面应用进行数据分析研究,还有一个监控站点统计的web service。 Woopra 有一个健壮的用户接口,一个允许你运行在多个网站和域名和直观的管理系统,甚至还提供一个聊天功能,因此你可以通过与访客交谈来收集非商业信息。 Woopra当前还处于beta版本,并且需要你请求一个私有数据beta注册。7. JAWStats& & & & JAWStats也是一个服务端的网站分析应用,它与最流行的 AWStats 协同运行(实际上,如果你是使用的共享主机计划的话,那么AWStats很可能已经安装好了)。 JAWStats 在awstats的基础上进行了两个扩展 - 依靠减轻服务器资源的使用来提升执行性能,在用户接口部分做了一点提升。8. 4Q& & & & 有很大部分的web分析涉及数字运算和数值数据。原始数据只告诉你事件的一部分,另外经常与实际用户进行交互的办法来处理分析数据也会非常的有用。 4Q 的开发人员 Avinash Kaushik 让这变得非常完美,他说:&web分析对于&what&非常适用,但却不适用&why& &。4Q是一个简单的调查应用,专注于使用实际用户的反馈来补充和提升你的传统网站分析数字。下面有个YouTube video 会告诉你如何容易的安装 4Q web分析工具.9. MochiBot& & & & MochiBot是一个免费的web分析和跟踪工具,它特别为 Flash 资源设计。 使用 MochiBot,你可以看到什么人正在分享你的flash内容,人们视差了你的内容多少次,很好的帮助你跟踪你的flash内容是否被剽窃或非法转载。 安装 MochiBot 很轻快,只需要你可以简单的copy几行ActionScript到你需要监控的.fla文件中去。10. Grape Web Statistics& & & & 参考Grape Web Statistics在线演示& & GrapeWebStatistics是一个简单,开源的面向开发人员的网站分析应用。它有一个清爽和可用的接口,并且还有一个扩展的API可以定制你的安装。Grape后端采用PHP程序,你可以在任何运行PHP的操作系统上使用该工具。& & 本文出自:/articles/view/& & 原文链接:/usabilityaccessibility/10-promising-free-web-analytics-tools/
声明:该文章系网友上传分享,此内容仅代表网友个人经验或观点,不代表本网站立场和观点;若未进行原创声明,则表明该文章系转载自互联网;若该文章内容涉嫌侵权,请及时向
上一篇:下一篇:
相关经验教程
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益
的原创经验被浏览,获得 ¥0.001 收益
的原创经验被浏览,获得 ¥0.005 收益是一套基于Php+MySQL技术构建的开源网站访问统计系统。Piwik可以给你详细的统计信息,比如网页 浏览人数, 访问最多的页面, 搜索引擎关键词等等,并且采用了大量的AJAX/Flash技术,使得在操作上更加便易。此外,它还采用了插件扩展及开放API架构,可以让开发人员根据 自已的实际需求创建更多的功能.
Piwik的架构设计比较通用,可以开发插件进行扩展。
Piwik的数据显示比较强大,至少看上去如此。例如有曲线图,直方图,饼图,标签云等等。插件可以通过拖拽的方式任意布置。
开源,免费,并且有相对完整的文档。
在线演示地址:
Our vision is to liberate web analytics by building an open platform which will create innovation in the analytics world.
New beautiful theme for Piwik: Morpheus is a flat design theme designed to let you focus on your analytics.
Launch of the Piwik Marketplace for
Browse and install plugins and themes from within your Piwik, in one click. Maybe you would like to try the new
We hope there will be many ‘third party plugins’ available on the Marketplace in 2014 – .
新特性详细信息列表:
Theming: Let Artists change the Look and Feel of Piwik!
New Default Theme design for Piwik 2: Morpheus
Add a new column in all reports for % percentage of visits
New “Visitor Profile” report showing all info about a specific Visitor
Anonymize IP should anonymize IPv6 addresses
Make “All Websites Dashboard” usable with 20,000+ websites
Option to use raw IP for more accurate Geo location instead of the anonimized IP
Add support for segmentation on Goals.getItems* API
Make sure Piwik works on IE8+
Marketplace Release
Plugins Marketplace project, available at plugins.piwik.org
Piwik Plugins Marketplace in Core: list, install and manage new Third Party Plugins
Make Plugins and Themes listings clear and beautiful
Create Github webhook for Piwik Plugins to release new versions
Move some core plugins to the Marketplace
New Treemap Visualization plugin
New LeftMenu plugin which move the horizontal menu to a vertical one
Core Platform Upgrades
Upgrade Piwik 2.0 codebase to PHP 5.3
Convert Piwik classes (core + plugins) to use PHP Namespaces
Migrate our templating engine from Smarty to Twig
Migrate CSS to LESS for easier Theming (eg. Color customization refactored)
Review list of Event names, Piwik 2 plugin hooks
Convert Translations files of core and plugin to use simple json format
Update jQuery / jQueryUI & jqPlot
Check Piwik 2.0 runs well on WAMP
Remove all files called functions.php and use static helpers instead
Use Singleton parent class app-wide
Increase minimum PHP version required to 5.3.2
refactor ArchiveProcessor & Plugins Archiver mechanism
Update TCPDF to latest version
Make it easier to profile via XHProf
Remove Zend_Registry from Core/Plugins
Remove compat code for PHP older than 5.3
Tests & QA
New Screenshot tests for Continuous User Interface Testing
Run Piwik.js javascript tests on continuous integration
Enable Continuous Integration on MYSQLI
Start of Developer Guides Project
New site developer.piwik.org for listing Piwik Platform Developer docs
Migrate dev docs from piwik.org to developer.piwik.org
Provide useful Plugin Developer Documentation
Create Framework Documentation for developers (php source code doc)
Document Hook Events for plugin developers
Automatically generate PHP Source code documentation for developers (classes, methods)
Update ExampleUI plugin with latest widget APIs
Plugins Framework
Separate Active plugins from Inactive plugins in the Plugins page
Plugin metadata in piwik.json file
Piwik Plugin files generator to easily create your first plugin!
Allow plugins to define new Visualizations and custom ViewDataTable
Allow plugins to bundle unit tests files
Plugins API: let plugins customize datatable footer icons
Let Plugin developers easily store Settings and customize them via UI
New Notification service: Let Plugin developers easily output info, notice, warning, error messages on screen
Plugins define translations they need as a hook: Remove _js hack!
Let Plugins define Schema changes
Let Plugins add new Console Tasks
Add link to install a plugin by uploading the .zip file
Add link to uninstall a plugin
Publish plugin “TreemapVisualization” on the plugin marketplace
Publish plugin “SecurityInfo” on the plugin marketplace
Publish plugin “VisitorGenerator” on the plugin marketplace
Move PleineLune to Marketplace
Bugs fixes & improvements
Allow ViewDataTables to be rendered via metadata alone
Fix all Phpstorm php warnings in Inspection tool
Detect clicks from Adwords as Referrer = Campaign and set the keyword to the host website that sent the visitor
NON BREAKING API CHANGE: Plugin Referers now called Referrers
NON BREAKING API CHANGE: Plugin PDFReports now called ScheduledReports
Faster Date Ranges: should use Year archives when period contains a full year
New config setting: disable Marketplace feature
[Marketplace] Add API to return developer information
Enable Plugins Marketplace menu in Piwik
DevicesDetection breaks Seamonkey browser recognition
Fix segmentation using ‘deviceType’ segment
Missing Device Brand icons
desktop vs mobile report user gets notice “No data for this graph”
Bug: When adding urls to a site the german umlauts are not handled correctly
Evolution of date range fails to export data
remove outdated code from Example* plugins
OPcache breaks update
Move Plugin getInformation() function call to piwik.plugin.json file
Zambian kwacha ISO code was changed
MultiSites.getAll: Add option to not remove sites that have no visits
when archive.php is run multiple times, each concurrent run should archive different websites
Error: Class ‘Piwik_UserCountry_LocationProvider’ not found
Disable all third party plugins after update to 2.0
UserAgentParser.php: use actual IE version instead IE7 when in compatibility mode
Set User-Agent for import_logs.py
show city instead of GPS (lat/long) in visitor log
Plugin documentation generator – add support for inline tag link
Hook documentation generator – add links to classes and methods in the developer guides and auto generated docs
Customize the javascript tracking tag via getJavascriptTag API call parameters
Improve accuracy of visit count attribute and segment
Replace existing feedback messages with Notifications
developer.piwik.org improvements
archive.php new parameter –force-idsites=1,2,n to process archiving only on the specified idsites
archive.php new parameter –skip-idsites=1,2,n to skip archiving for specified idsites
New hook to let plugins change the attributes for a website
Add new ‘type’ column to piwik_site table, defaults to ‘website’
Console command to generate unit tests or integration tests for a Plugin
Make Visitor log look good when viewed a s widget in the dashboard
New segment filter type: custom events name, category, action
Support transparent background custom logos
Metadata filter_truncate slightly buggy: “Others” shows as “Othersh” in the VisitTime output
New search engines
Date Range is not correctly recognized in Metadata API
“&” characters are transformed to “&” in pagetitles of tracked goals when editing them
getUserPreference bug: “defaultReport” preference is “false” by default
Report Visits Summary, Weekly report shows last Day’s summary
Evolution graph fails to load and returns stack trace for Actions.getPageUrls
Piwik detects Opera 15 as Chrome 28
false province name on the austria map
API method API.getBulkRequest converts whitespace to HTML entities
Wrong message text when deleting a widget (sometimes)
Incorrect define() signature
iPod Touch – DeviceType
check website name is url decoded
FAQ: Bad default value for proxy_host_headers[]
archive.php outputs messages when pre-processing segments
Dashboard Suggestions
Make PDF Reports Truncation limit configurable in config file
Creating a segment using the visitor IP “visitIp” should work for users with ‘view’ access
no data with selected “date range” and flat table
Bug when exporting report
Problem with API method Live.getLastVisitDetails and filter_offset
import_logs.py autodetection hangs
Remove the /.git test in the System Check file integrity
Do not report visits from Google PageSpeed-Insights
Segment editor visitor IP range as filter
Wrong argument substitution in spanish translation
Tracking code has double slashes
Add Vimeo and YouTube to SocialNetworks
Add video.search.yahoo.co.jp to Search Engines
missing info popup at visitor log
Installation is broken when trying to re-use tables
Properly handle bulk tracking
PiwikTracker should load the visitor ID from the first party cookie if available
Make campaign name and campaign keyword lowercase when tracking
Set first party client cookies from PiwikTracker.php to improve dual JS-PHP tracking and data accuracy
Notice on bulk import when authenticateSuperUserOrAdmin is called
Bulk import API
Actions & Downloads exports only combined statistics per site, it should be possible to export statistics per file
Actions & Downloads flattening or aggregating reports with lots of date results in: There is no data for this report.
MySQL Warning: Statement may not be safe to log in statement form
error when creating an email-report with a Custom Segment as a normal user (works for admin)
Archive.php triggered multiple times simultaneously can result in mysql deadlock situation
UpgradePHP json_decode doesn’t work for assoc = TRUE
fields config_os_version and config_device_type are not large enough
GD with JIS-mapped Japanese Font Support
Detect windows 8.1
Segment attribute not kept during live widget updates
Visit summary graph is cached in mail client
geoip DB automatic update doesn’t respect update period
When embedding the custom dashboard and using &token_auth the sparklines should also work
import_logs.py: ValueError: invalid literal for int() with base 10: ‘-’
Problem in archive script
visitor-Profile: “location” bug + enhancement
Campaign Reports don’t work with IE8
User profile slowness in getAdjacentVisitorId()
archive.php should only process websites which exist
“wait” meesage sometimes partically hide
Integrity constraint violation: 1062 Duplicate entry ‘XYZ’ for key unique_idsite_idorder In query: UPDATE piwik_log_conversion
import_logs.py crashes on invalid requests
visitor log: not enough room, icons overlap when ecommerce conversions
“Notice: Array to string conversion” when downloading CSV or TSV files from Visitor Log in 1.12
Message for THEME activation talks about PLUGIN
Allow bar graph as well as line graph
API request Referers.getUrlsForSocial fails with idSubtable
Visits over time Graph fails to load with 3 metrics
SecurityInfo Plugin: Cannot get rid of warning
Generating scheduled reports fail for date ranges
Opt-out/in iframe code is not following HTML standard
API Bulk Requests: invalid output when multiple dates and format is xml
Segment Editor should work to list segments in IE8

我要回帖

更多关于 piwik 开发 的文章

 

随机推荐