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追踪器部署系列之一:安装跟踪代码》有25条评论

  1. The way this post is written makes the whole discussion feel very easygoing and easy to follow, while also keeping enough substance in the topic to make readers interested in sharing their own opinions and continuing the conversation further.

    casino en ligne fiable

  2. This is a remarkably helpful breakdown of the subject matter. You have successfully captured the most essential elements and presented them in a completely neutral, straightforward manner that allows anyone to easily grasp the underlying concepts without feeling overwhelmed.

    pokies online

  3. I like how this post keeps a natural and approachable tone while still presenting the ideas in a easy-to-follow and nicely arranged format, because that combination makes the content more enjoyable and helps keep readers interested from the first part to the last.

    VIAGRA FOR SALE HERE

  4. I just wanted to drop a quick note to express my thanks for this excellent piece of writing. The clean formatting and objective perspective you maintained throughout the entire text make it an absolutely fantastic starting point for anyone looking to learn more right now.

    non uk casino

  5. I have been looking for a reliable breakdown like this for a while now, and your post delivered exactly what I needed in a format that is both visually pleasing and intellectually satisfying to read through during my break.

    casino italiani non aams

  6. There is a really good flow throughout this post that keeps the discussion easy to understand and enjoyable to follow, while also maintaining a measured tone that works well for a broad audience of different readers.

    siti non aams sicuri

  7. Your ability to take this information and present it in such an unbiased and easily readable format is greatly appreciated, and I will be sure to recommend this specific page to anyone else who might be searching for similar insights.

    australian online pokies

  8. Thank you for putting together such a well-organized and meaningful piece of content; the way you have structured the information makes it incredibly clear to follow and ensures that the main message is communicated highly effectively.

    non gamstop casinos uk

发表评论

ICP证:苏ICP备15038038号-2