Triggering a new visit manually

We would like to trigger a “new visit” manually on demand.
This is meant to create new visits (but with the same user) when tracking custom vars, and the conditions (custom vars) change.

The first attempt has been to remove the session cookie, but Piwik will still get the previous visit id via recognizeTheVisitor.
This behavior is meant to prevent abuse, and might get changed by setting trust_visitors_cookies, but that’s not the proper way of addressing this probably, is it?

Is there a supported way to make Piwik create a new visit, without the visit/session timeout being reached?

It appears the session cookie is only used for referrer counting, setting the refname cookie (in getRequest)?!

btw: looking at recognizeTheVisitor, it seems like a quite some code is only relevant for when trust_visitors_cookies=true, like the $found and $idVisitor handling (which do not get used by default).
This should get moved to the trust_visitors_cookies==true conditional block, if I’m not missing anything here.

It is not possible yet, but will be soon, see #2222 when you can force the visit to be recorded for a given idvisitor. Then you could generate a random idvisitor. However it will only be possible via the Tracking API (not JS) at first, as it will require the token_auth to be passed

While the changes in/for Paypal tracking: Tracking API improvements & how to · Issue #2222 · matomo-org/matomo · GitHub look interesting, it does not provide the possibility to create a new visit yet, does it?
Would you have to use a random/unused visitid to trigger this?

Yes, generate a random ID will work

see new feature: How to - Analytics Platform - Matomo

you can also now call on the PHP tracking API the function setForceNewVisit(true) which will force a new visit to be created for the request. See PHP Tracker: new method setForceNewVisit() to force creation of a new visit · Issue #5123 · matomo-org/matomo · GitHub