Maintain visitor ID between JS and HTTP API before login

Hi,

I’m wondering if it possible to reliably track activity against the same “Unique Visitor” when using a combination of JS and HTTP API’s.

Use case is as follows:

  • JS API is used for tracking of all HTML page requests (several custom dimensions are populated from CMS for each page.
  • HTTP API is uses for tracking of all downloads (same logic used as per HTML requests for populating of custom dimensions) - This is done via HTTP rather than JS in order to avoid the requirement to identify and appropriately tag every download link with the appropriate custom dimensions - especially as this could become a significant performance overhead on some of the longer lists of files within this web app.
  • Once a user has logged in to the CMS, User ID will be set (both for JS API and HTTP API) however, some downloads are available before a user logs in - and these need to be tracked against the same “unique visit” as the HTML page requests.
  • For anonymous requests, tracking appears to be maintained across requests based on the unique visitor ID (_id on the HTTP API) which appears to be being stored as part of the _pk_id.1.3c57 cookie
  • _pk_id.1.3c57 cookie could be read by the web app, and the _id value could be extracted - however, this cookie looks like it could change between versions.

So… is it possible to clarify,

  • Can we rely on the _pk_id.1.3c57 cookie not being renamed in a subsequent version of Matomo? (we are using Matomo Cloud if this makes any difference)
  • Is there a more appropriate way of achieving the same desired results?

Thanks for your assistance.

Hi, did you solve the problem? I’m facing a quite similar one now. Do you know how can I get a user’s _id in backend API?