Start new visit with javascript client


#1

I need help in trying to create a new visit whenever a visitor lands on a specific page; I tried using “new_visit=1” as per How to - Analytics Platform - Matomo WITHOUT deleting the cookies (I want to start a new visit for the existing visitor, NOT create a new visitor) but this causes another problem where the visit count is never incremented due to it being maintained by the js client. Looking at the js client implementation this only seems to occur when the session expires. I tried manually deleting the session cookie but this still doesn’t work since it also checks the lastVisitTs in the visitor cookie before incrementing the visit count! (see reference code below). Is there a way to do this thru the js API that I’m missing? (without modify the js client API code of course). Thanks!


                if (!cookieSessionValue) {
                    // cookie 'ses' was not found: we consider this the start of a 'session'

                    // here we make sure that if 'ses' cookie is deleted few times within the visit
                    // and so this code path is triggered many times for one visit,
                    // we only increase visitCount once per Visit window (default 30min)
                    var visitDuration = configSessionCookieTimeout / 1000;
                    if (!cookieVisitorIdValues.lastVisitTs
                        || (nowTs - cookieVisitorIdValues.lastVisitTs) > visitDuration) {
                        cookieVisitorIdValues.visitCount++;
                        cookieVisitorIdValues.lastVisitTs = cookieVisitorIdValues.currentVisitTs;
                    }