jcubic
jcubic

Reputation: 66478

How to save visit url in Matomo image tracking?

I have image based tracking using Matomo I want to track usage of my bookmark from Open Source library that I'm working on.

This is my code:

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;

it save the action but it's marked as single visit and I would like each invocation to be saved separately and URL of the visited page would not be referer but URL of the visit. So I would know that visited urls are eather someone copy my tracking code and cloned the project website or used the bookmark.

From what I see action_name: 'bookmark' appear as clicks inside real time visit and urlref appear in referrer panel. And the visit is marked as URL not provided.

After enabling debugging I see this message:

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

How to specify the url of the visit using Matomo image tracking?

Upvotes: 0

Views: 137

Answers (1)

mattab
mattab

Reputation: 369

To specify the URL, you can set the &url= parameter (URL encoded) in the Tracking API request. Learn more in the Tracking API reference: https://developer.matomo.org/api-reference/tracking-api

Upvotes: 1

Related Questions