生活资讯
piwik 、piwik pro
2023-04-05 01:40  浏览:39

如何在wp中定义piwik自定义变量

PIWIK默认的自定义变量为5,要在此基础上调整,需要跑到console端上执行下命令,这里记录一下,免得以后忘了。

操作:

Python

[root@AY14070313210045657aZ seo]# ./console customvariables:info

PHP Warning: PHP Startup: geoip: Unable to initialize module

Module compiled with module API=20121212

PHP compiled with module API=20090626

These options need to match

in Unknown on line 0

****************************************************

Your Piwik is configured for 5 custom variables.

****************************************************

[root@piwik seo]# ./console customvariables:set-max-custom-variables 10

PHP Warning: PHP Startup: geoip: Unable to initialize module

Module compiled with module API=20121212

PHP compiled with module API=20090626

These options need to match

in Unknown on line 0

Configuring Piwik for 10 custom variables

Scope "Page"

5 new custom variables having the index(es) 6 - 10 will be ADDED

Scope "Visit"

5 new custom variables having the index(es) 6 - 10 will be ADDED

Scope "Conversion"

5 new custom variables having the index(es) 6 - 10 will be ADDED

Are you sure you want to perform these actions? (y/N)y

Starting to apply changes

1/15 [=--------------------------] 6% Added a variable in scope "Page" having the index 6

2/15 [===------------------------] 13% Added a variable in scope "Page" having the index 7

3/15 [=====----------------------] 20% Added a variable in scope "Page" having the index 8

4/15 [=======--------------------] 26% Added a variable in scope "Page" having the index 9

5/15 [=========------------------] 33% Added a variable in scope "Page" having the index 10

6/15 [===========----------------] 40% Added a variable in scope "Visit" having the index 6

7/15 [=============--------------] 46% Added a variable in scope "Visit" having the index 7

8/15 [==============-------------] 53% Added a variable in scope "Visit" having the index 8

9/15 [================-----------] 60% Added a variable in scope "Visit" having the index 9

10/15 [==================---------] 66% Added a variable in scope "Visit" having the index 10

11/15 [====================-------] 73% Added a variable in scope "Conversion" having the index 6

12/15 [======================-----] 80% Added a variable in scope "Conversion" having the index 7

13/15 [========================---] 86% Added a variable in scope "Conversion" having the index 8

14/15 [==========================-] 93% Added a variable in scope "Conversion" having the index 9

15/15 [============================] 100% Added a variable in scope "Conversion" having the index 10

*********************************************************

Your Piwik is now configured for 10 custom variables.

*********************************************************

[root@AY14070313210045657aZ seo]# ./console customvariables:info

PHP Warning: PHP Startup: geoip: Unable to initialize module

Module compiled with module API=20121212

PHP compiled with module API=20090626

These options need to match

in Unknown on line 0

****************************************************

Your Piwik is configured for 5 custom variables.

****************************************************

[root@piwik seo]# ./console customvariables:set-max-custom-variables 10

PHP Warning: PHP Startup: geoip: Unable to initialize module

Module compiled with module API=20121212

PHP compiled with module API=20090626

These options need to match

in Unknown on line 0

Configuring Piwik for 10 custom variables

Scope "Page"

5 new custom variables having the index(es) 6 - 10 will be ADDED

Scope "Visit"

5 new custom variables having the index(es) 6 - 10 will be ADDED

Scope "Conversion"

5 new custom variables having the index(es) 6 - 10 will be ADDED

Are you sure you want to perform these actions? (y/N)y

Starting to apply changes

1/15 [=--------------------------] 6% Added a variable in scope "Page" having the index 6

2/15 [===------------------------] 13% Added a variable in scope "Page" having the index 7

3/15 [=====----------------------] 20% Added a variable in scope "Page" having the index 8

4/15 [=======--------------------] 26% Added a variable in scope "Page" having the index 9

5/15 [=========------------------] 33% Added a variable in scope "Page" having the index 10

6/15 [===========----------------] 40% Added a variable in scope "Visit" having the index 6

7/15 [=============--------------] 46% Added a variable in scope "Visit" having the index 7

8/15 [==============-------------] 53% Added a variable in scope "Visit" having the index 8

9/15 [================-----------] 60% Added a variable in scope "Visit" having the index 9

10/15 [==================---------] 66% Added a variable in scope "Visit" having the index 10

11/15 [====================-------] 73% Added a variable in scope "Conversion" having the index 6

12/15 [======================-----] 80% Added a variable in scope "Conversion" having the index 7

13/15 [========================---] 86% Added a variable in scope "Conversion" having the index 8

14/15 [==========================-] 93% Added a variable in scope "Conversion" having the index 9

15/15 [============================] 100% Added a variable in scope "Conversion" having the index 10

*********************************************************

Your Piwik is now configured for 10 custom variables.

*********************************************************

piwik 统计工具的趋势分析图 从数据库里能改吗?

你只需将一小段代码放到将要统计的网页中即可。安装完成后Piwik是一个PHP和MySQL的开放源代码的Web统计软件. 它给你一些关于你的网站的实用统计报告,比如网页浏览人数,你可以添加新的功能或是移除你不需要的功能,Piwik同样可以安装在你的服务器上面,数据就保存在你自己的服务器上面。你可以非常容易的插入统计图表到你的博客或是网站抑或是后台的控制面板中, 访问最多的页面, 搜索引擎关键词等等… Piwik拥有众多不同功能的插件。

piwik怎么实现token登陆验证

piwik怎么实现token登陆验证

输入两个整数,输出其中的大数。

改用if-else语句判别a,b的大小,若a大,则输出a,否则输出b。

3. 第三种形式为if-else-if形式

前二种形式的if语句一般都用于两个分支的情况。 当有多个分支选择时,可采用if-else-if语句,其一般形式为:

if(表达式1)

语句1;

else if(表达式2)

语句2;

else if(表达式3)

语句3;

else if(表达式m)

语句m;

else

语句n;

其语义是:依次判断表达式的值,当出现某个值为真时,则执行其对应的语句。然后跳到整个if语句之外继续执行程序。 如果所有的表达式均为假,则执行语句n。然后继续执行后续程序。 if-else-if语句的执行过程如图3—3所示。

【例5.5】

#include"stdio.h"

main(){

char c;

printf("input a character: ");

c=getchar();

if(c32)

printf("This is a control charactern");

如何开发 Piwik 插件

1,插件的作用

1,收集目前piwik目前不能跟踪的数据

2,定义新的小物件(widgets)能够用当前可用的或者新的数据形成可见的图像等。(类似形成报表?)

3,定义新的或者覆盖已经存在的项目来定制我们自己的Piwik

4,提供某种API,并且自动生成我们易于理解的数据格式。

2,统计跟踪是如何工作的。

在我们开始写我们自己的插件之前,我们要知道piwik是如何跟踪并且加工数据的。***的办法是我们安装一个新的Piwik程序,并观察他的数据库布局。

数据库图示地址:

3,跟踪:

每当有访问者来访问我们可用piwik的网站的时候,Javascript都会提交一个访问过piwik.php脚本的关于访问者以及访问页面的最基本的数据设置信息,这个脚本会携带合法的数据,并将他存放到数据库中去。跟踪插件能够修改并添加数据

例如:

_log_visit 表:存储每个新的访问实体

_log_link_visit_action:访问者随后访问的页面。

_log_action: 目前为止,piwik追踪到的目前访问者访问过的页面作为实体存放到这类表中。这类表是被_log_link_visit_action引用的。

4,处理

未加工的数据是指在我们追踪过程中不能被直接展示出来的数据。对于数据库来说,计算所有的请求负荷太高。因此,piwik处理这些数据为可视化,这个处理叫做存档。

当你访问piwik接口的时候就会产生存档。在高流量网站上,存档应该由cronjob来完成,原数据被处理并放到存档表中。

5,存档

每个月的由piwik监测的数据,在数据库中会创建两个表,这两个表分别为:_archive_YEAR_MONTH,_archive_numeric_YEAR_MONTH,包含的内容为那个月的处理数据

比如2013-06那么对应的表为:piwik_archive_2013_06,piwik_archive_numeric_2013_06

6,插件结构:

文件结构:

插件都放在plugins/文件中,每个插件都是它的子文件夹

plugins/

|-- VisitFrequency

| |-- API.php

| |-- Controller.php

| |-- templates

| | |-- index.tpl

| | `-- sparklines.tpl

| `-- VisitFrequency.php

多数的插件都不少与3个php文件和一些视图模板。

基本布局

为了能够让piwik插件能够工作,插件系统要遵循一些约定

a:插件要有一个和它所在插件目录名称相同的php文件。所以如果你想开发一个名为VisitorForeCast的插件,就需要创建一个名为 VisitorForeCast的目录,并且目录里包含一个名为VisitorForeCast.php文件。

b:创建一个继承Piwik_Plugin类的Piwik_VisitorForeCast 类

?php class Piwik_VisitorForecast extends Piwik_Plugin { }

plugins/VisitorForecast/VisitorForecast.php

Piwik_Plugin有一个抽象方法getInformation()的抽象类,我们要继承,他的返回值为如下内容,当然也可以参考其他插件,下面内容为core/Plugin.php 内容,这个数组必须返回一个关联数组,这个数组包含有关于这个插件相关信息。

VisitorForeCast.php 文件的完整内容为:

?php

class Piwik_VisitorCast extends Piwik_plugin {

public function getInformation() {

return arr***(

'description' = 'Provide a forecast of visits for the d***',

'***thor' = 'Your Name',

'***thor_homepage' = '',

'homepage' = '',

'license' = 'GPL v3 or later',

'license_homepage' = '',

'version' = '0.1',

'translationAvailable' = false,

);

}

}

?

7,翻译

Piwik可用超过45种语言,当我们想要创建我们习惯的插件的时候,我们可以利用piwik国际化的特性。如果想让我们的插件支持转译(translations),我们需要 在getInformation方法中设置‘translationAvailable’=true,设置完之后,Piwik将会在我们的插件的子文件夹lang/中寻找这个支持翻译功能的字符串,无论我们想支持那种语言,我们都要准本一个用ISO(介),639-1(),alpha-2()命名的php文件。

每个语言文件(langle file)都要包含一个名字为:$translations的关联数组,这个数组的键($key)映射到某个提供翻译(translation)的文件。而这些键($keys)是所有的提供翻译的文件之间共享的。当我们切换支持不同语言的时候,所依赖的正是这个语言文件。通常,这些键是用插件的名字作为前缀,例如,我们的VisitorForecast插件,如果想支持英文翻译那么就要命名为en.php ,完整路径(pugins/VisitorForecast/lang/en.php),内容如下

?php

$translations = arr***('VisitorForecast_PluginDescription'='')

?

现在,我们给了翻译文件一个描述行的键(VisitorForecast_PluginDescription),这样一来,翻译者工作起来就非常容易。Piwik提供了一个名为Piwik_Translate($key)方法,它将会根据(依赖)用户选定语言返回用户想要的转化语言版本。

public function getInformation() { return arr***( 'description' = Piwik_Translate('VisitorForecast_PluginDescription'),

[..]

);

}

Plugin Information with i18n

好了,翻译的内容基本介绍完了,有点晕。。。我们来整理下思路,如果看过wordpress的,可能会觉得有些地方有点像,都是为开发插件提供了***的便利。便于部署,而不用动核心代码。

现在我们已经有两个文件。

1,Piwik_VisitorForecast.php, 它和插件的名字基本相同,只是用Piwik做为前缀,并且,他要继承Piwik_Plugin类。它有一个方法名字叫getInformation(),它返回一个关于我们开发插件的描述信息,作者,作者的主页,版本信息等。到现在此文件中的内容应该是如下内容

class Piwik_VisitorForecast extends Piwik_Plugin{

public function getInformation() {

$info = arr***(

//注意:VisitorForecast_PluginDescription'是我们在en.php文件中数组的键

'description' =Piwik_Translate('VisitorForecast_PluginDescription'), '***thor'='***thor_name',

'***thor_home'='home page', 'version'=Piwik_Version::VERSION,

);

return $info;

}

}

2,en.php文件:他主要是为Piwik_Translage方法提供那个键,使得他获取到en.php文件中的内容,那例子中的en.php文件中的内容就应该是下面这样的。

命名为en.php ? 为什么,上边说了他要符合ISO,639-1,alpha-2的命名,具体可以看上边三个字母后面的链接。就知道为什么是en.php 而不是eng.php了。

?php

$translations = arr***(

'VisitorForecast_PluginDescription'='Provide a forecast of visits for the d***',

);

?

8,Hooks(钩子,wordpress中也有,我们部门经理(大牛)很提倡用wordpress哦!)

在Piwik内部,用了一个名字叫EventDispatcher(事件调度)的PHP包。我们的插件能将一个函数钩到某个预定义的事件上,当事件触发的时候会调用这个函数。

如果我们的插件需要注册任何钩子,我们就需要在我们的插件类中实现getListHooksRegistered 方法。还必须要返回一个数组,将钩子的名称和回调函数映射。

比如说,如果你的插件想要注意到每个新的访问者,Piwik提供了一个叫Tracker.newVisitorInformation

钩子,每当Piwik跟踪到一个新的访问者的时候,它就会被触发。

public function getListHooksRegistered(){

return arr***(

'Tracker.newVisitorInformation'='addVisitorInformation'

);

}

public function addVisitorInformation($notification) {

//我们通过$notification参数的引用和钩子关联起来。

$visitorInfo = $notification-getNotificationObject();

//获取referrer_url

$url = $visitorInfo['referrer_url'];

//我们可以用这个url做一些事情

}

当事件触发的时候,回调函数会取回一个对象通知,这个对象的内容取决于钩子

piwik能做到哪些事情 知乎

Piwik是一个PHP和MySQL的开放源代码的Web统计软件. 它给你一些关于你的网站的实用统计报告,比如网页浏览人数, 访问最多的页面, 搜索引擎关键词等等… Piwik拥有众多不同功能的插件,你可以添加新的功能或是移除你不需要的功能,Piwik同样可以安装在你的服务器上面,数据就保存在你自己的服务器上面。你可以非常容易的插入统计图表到你的博客或是网站抑或是后台的控制面板中。安装完成后,你只需将一小段代码放到将要统计的网页中即可。

同时,做为一个开源项目软件,Piwik也鼓励开发人员对其功能进行扩展增强,他们将提供诸多便利来有助于你的二次开发工作。

如何在piwik中获得用户变量

如何在piwik中获得用户变量

(1)输入框的ID写法:easy_device.type(By.id('id/name_text),'zhangsan')。

(2)复选框/单选/按钮的ID写法:easy_device.touch(By.id('id/login_button'),MonkeyDevice.DOWN_AND_UP)。

(3)当两个ID名称相同时,可以使用层级进行定位。

easy_device.touch(By.id('id/parent_button'),MonkeyDevice.DOWN_AND_UP,By.id('id/current_button'),MonkeyDevice.DOWN_AND_UP)。

piwik的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于piwik pro、piwik的信息别忘了在本站进行查找喔。

发表评论
0评