New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration for new visit on new browser session #14739
Comments
Looking at the code this could work by calling
I haven't tested it though. I reckon it is indeed not enough for the _pk_ses cookie to create a new visit. There isn't really any other way for us to do this... You would also need to handle manually what should happen before the user logs in (eg for the one pageview where user is viewing the log in page etc). We can't really detect any newly created browser sessions unfortunately. Unless you have some way to do this on our code then you could create a PR and we would see if that works for us. |
Thanks for the quick feedback. The trouble I have with new_visit=1 is that parts of our site are not SPA, so that code would get loaded on multiple pages. I'd have to somehow determine whether the new_visit flag was already passed in once or not for this visit. Would creating a new cookie with a browser-session lifetime be something that would be considered? Then if the cookie doesn't exist, automatically create a new visit and a new session cookie. Or maybe leveraging the _pk_ses cookie in this way by making it have a session lifetime and then checking for it on the back-end (I'm not quite sure exactly what the _pk_ses cookie is currently for)? Taking a step back, is this generally considered to be not best practice? I would think that if a user closed the browser and then came back to the site some time later, it would make sense for that to be a new visit. Or do I misunderstand the definition of "visit"? Thanks again. |
Whether it makes sense is really up to you I guess. In general you might just want to set the This might actually give you the wanted behaviour. So you'd do this:
We won't be able to leverage _pk_ses cookie here I think. When you say browser session I'm not sure what you mean cause the session cookie only exists during browser session AFAIK unless you mean "Browser session = time the user is logged into your system". I would actually recommend you try the userId feature and it should give you what you want maybe. Otherwise you'll have to track an event on successful login. You should be able to detect this maybe in your application and send out that tracking code once. |
Thanks for the recommendation. Our website is a web app which (in most cases) requires a user to log in before using the site. In essence we're trying to get the concept of a "visit" to line up with our web app's "session" which begins when you login (by the regular tracking code) and ends when you close the browser or log out (I believe we can manually end the visit with When I'm talking about the "browser session", I mean from the start of the browser to when the browser is closed. The _pk_ses cookie now has an expiration of 30 minutes by default (we bumped it up to 120 to match our The UserID is a good feature that we're considering (we have some some GDPR concerns), but I'm not sure how it helps limit a visit to the lifetime of the browser session. Can you please elaborate? Thanks again for your help. |
Re GDPR: There is a feature to pseudo anonymize the user ID in Matomo Admin. It helps limit visit since you would basically unset the userId as soon as the user logs out (or it be no longer set) and therefore potentially create a new visit but I'm not quite sure.
This should be pretty much implemented by default but I might be wrong? |
Not to go too much off topic, but I was concerned by the comment in the UserId documentation that says "in GDPR terms: the User ID pseudonym still counts as personal data." Matomo doesn't appear to start a new visit when you open a new browser session if you still have your cookies from the last session and it's been less than |
Doesn't appear there is anything we have to do as part of this issue? will close, please re-open a new issue if there is something to fix |
…r Single Page Applications) Got the idea from matomo-org/matomo#14739 (comment)
* Update docs since resetUserId no longer creates new visit fix matomo-org/matomo#15293 cc @mattab can you have a look? * we also force a new visit to be created for the pageviews after logout * we make sure to not again create a new visit afterwards (important for Single Page Applications) Got the idea from matomo-org/matomo#14739 (comment) Co-authored-by: Matthieu Aubry <mattab@users.noreply.github.com>
Hello,
Is it possible to configure Matomo for a new visit to be automatically created when a new browser session is created? We have a site where you need to log in to create a browser session, and we would like the entire duration of that logged in session to be counted as one visit (which we can mostly do by extending the visit timeout), and any new browser session to be another visit. For example: a user logs in to and uses the site, that's visit 1; the user closes the browser, opens it right away and logs in to the site again, that's visit 2 (for the same visitor).
It appears that it's not enough for the _pk_ses cookie to be session based for a new visit to get created. I know that new_visit=1 can be used to manually trigger a new visit, but due to the complexity of our site it may be challenging to find a way to only fire off that code only once.
Have others tried to address similar requirements?
Thanks a lot.
-Igor
The text was updated successfully, but these errors were encountered: