如何在Matomo图片跟踪中保存访问网址?

问题描述

我使用matomo进行了基于图像的跟踪,我想从正在使用的开源库中跟踪书签的使用情况。

这是我的代码

const searchParams = new URLSearchParams({
  idsite: 7,rec: 1,action_name: 'bookmark',urlref: location.href
});
const url = new URL('https://piwik.jcubic.pl/matomo.PHP')
url.search = searchParams.toString()

var img = new Image();
img.src = url.href;

它保存了操作,但是将其标记为单次访问,​​我希望将每次调用分别保存,并且访问页面的URL不是引用,而是访问的URL。因此,我知道访问的URL就是有人复制了我的跟踪代码并克隆了项目网站或使用了书签。

从我看到的action_name来看:“书签”显示为实时访问中的点击,而urlref出现在引用面板中。并将该访问标记未提供网址

启用调试后,我会看到以下消息:

[2020-09-22 10:02:30] piwik.DEBUG: WARNING: URL looks invalid and is discarded [] {"class":"Actions","request_id":"a1a8b"}

如何使用matomo图像跟踪指定访问网址?

解决方法

要指定URL,可以在Tracking API请求中设置&url=参数(URL编码)。在Tracking API参考中了解更多信息:https://developer.matomo.org/api-reference/tracking-api