Debian11上安装Matomo
Xplorist Lv6

Debian11上安装Matomo

reference-site-list

steps

环境准备:

    1. PHP 2. MySQL 3. Nginx

安装

  • 将zip文件下载后上传到Nginx的/usr/share/nginx/html/keep目录下, 解压
1
2
3
4
5
6
7
cd /usr/share/nginx/html

unzip matomo.zip

mv /usr/share/nginx/html/matomo /usr/share/nginx/html/keep/matomo

chmod -R -f 777 /usr/share/nginx/html/keep/matomo
  1. Welcome!

欢迎介绍界面,直接点击Next

  1. System Check

自动进行系统检查,如果有缺少的依赖,就要自己去安装相应的依赖

  1. Database Setup

MySQL数据库设置

  1. Creating the Tables

创建数据表

  1. Super User

超级用户设置

  1. Setup a Website

设置一个网站

  1. JavaScript Tracking Code

JavaScript追踪代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//xplorist.tech/matomo/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
  1. Congratulations

恭喜结束界面, 后面两个选项的勾去掉,功能会更强

使用

  • 在hexo keep中使用Matomo,找到/keep/themes/keep/layout/_partial/head.ejs, 在head标签的最后添加如下代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
var currentUrl = location.href;
_paq.push(['setCustomUrl', currentUrl]);
_paq.push(['setCustomVariable', 1, 'PageName', '<%= title %>', 'page']);// 【要修改】XXX页面名称为需要制定统计的页面名称或模块名称,不能乱写,不然统计数据会出问题

_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//xplorist.tech/matomo/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);// 【要修改】'xxxTheSiteId'为matomo系统中注册的站点id,不能乱写
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+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->

这是之前在foxconn里面自己修改的多功能版本,当然也可以使用第7步骤里的原生的代码,简洁清爽,数据库里杂乱的数据更少

访问自己的Matomo

WordPress中使用Matomo

 评论