Matomo追踪器部署系列之一:安装跟踪代码

依照下面的步骤即可找到对应的代码:

  1. 以管理员或者超级用户身份登陆Matomo
  2. 点击右上角菜单中的用户名旁边的小齿轮图标(Settings)访问管理功能
  3. 点击左菜单的Tracking Code

将Tracking Code复制并粘贴到网页的<body>标签之后或者放到<head>中

欢迎加入Matomo中文网官方QQ群255820112(点击滚动至本页末可扫描二维码),随时提问,有问必答。



在你的追踪代码中,{$PIWIK_URL}请用你的Matomo服务器地址进行替换,{$IDSITE} 请用你的网站ID进行替换。

这些代码对熟悉JavaScript的程序员来说可能有点奇怪。这种代码方式是为了方便异步运行。换句话说,浏览器无需等待piwik.js加载完成即可显示网页。

为了异步追踪,配置和追踪调用被追加到_paq数组中,它无需依赖piwik.js的异步加载,格式如下: _paq.push([ ‘API_method_name’, parameter_list ]);

你也可以将方法加入到_paq数组中以备执行。比如:

你也可以将方法加入到_paq数组中以备执行。比如:

var visitor_id;
_paq.push([ function() { visitor_id = this.getVisitorId(); }]);

或者比如,使用异步代码获取自定义变量(name, value):

_paq.push([‘setCustomVariable’,’1′,’VisitorType’,’Member’]);
_paq.push([ function() { var customVariable = this.getCustomVariable(1); }]);

即使在piwik.js加载并运行之后,也可以将执行代码加入_paq数组。 如果你的Matomo追踪代码和上面展示的有所区别,那可能是你的版本已经不推荐使用了。老版本仍然可以工作,但我们强烈建议你使用最新版本的追踪代码。

《Matomo追踪器部署系列之一:安装跟踪代码》有28条评论

  1. Join the top-notch world of online gaming where endless fun awaits. Bovada offers top table games and no-deposit bonuses for all players. With Bovada, enjoy thrilling wins and secure, reliable entertainment every day!

  2. La sante est un droit, la rendre accessible est notre mission. Nous vous offrons le meilleur de la pharmacie sans les contraintes geographiques. Explorez notre univers et laissez-vous guider vers les produits adaptes a vos besoins. Respirez, votre pharmacie est en ligne.eurax

  3. Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?

发表评论

ICP证:苏ICP备15038038号-2