Skip to content
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

Matomo 4 doesn't merge not logged visits when a user logs-in #16949

Closed
AAudusseau opened this issue Dec 14, 2020 · 12 comments
Closed

Matomo 4 doesn't merge not logged visits when a user logs-in #16949

AAudusseau opened this issue Dec 14, 2020 · 12 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@AAudusseau
Copy link

Hi everyone, I would like to track some events from the server side, and before Matomo I was unable to do it because of this issue : #15593

Now the problem is gone, but the behavior describe here is not true anymore. Visit when the user was not logged are not merged anymore after setting the user ID.

@tsteur
Copy link
Member

tsteur commented Dec 14, 2020

Hi @AAudusseau

you can get the previous behaviour as it was under Matomo 3 by setting the following config in your config/config.ini.php:

[Tracker]
enable_userid_overwrites_visitorid = 0

I've also tweaked the guide slightly to mention this

@tsteur tsteur closed this as completed Dec 14, 2020
@tsteur tsteur added the answered For when a question was asked and we referred to forum or answered it. label Dec 14, 2020
@AAudusseau
Copy link
Author

Hi @tsteur,

Thanks for your answer. I saw this option, but unfortunately I use a cloud-hosted instance so I can't change the configuration myself and I suppose it is enabled by default. I think I need the Matomo 3 behavior and force the visitorId from the server side.

About your changes in the guide, the part "When a visitor connects to your website and is not logged-in (User ID is not set)" is still wrong when the option is enabled (this is the purpose of this issue).

And also I look a bit in the code, and there is duplicate code here : https://github.com/matomo-org/matomo/blob/4.x-dev/core/Tracker/Visit.php#L585, probably a merge mistake 😉

@sgiehl
Copy link
Member

sgiehl commented Dec 15, 2020

And also I look a bit in the code, and there is duplicate code here : https://github.com/matomo-org/matomo/blob/4.x-dev/core/Tracker/Visit.php#L585, probably a merge mistake 😉

Thanks for that hint. Will create a PR to change that 👍

sgiehl added a commit that referenced this issue Dec 15, 2020
@sgiehl sgiehl mentioned this issue Dec 15, 2020
9 tasks
diosmosis pushed a commit that referenced this issue Dec 16, 2020
@tsteur
Copy link
Member

tsteur commented Dec 16, 2020

I use a cloud-hosted instance so I can't change the configuration myself and I suppose it is enabled by default.

Just FYI if you're using Matomo Cloud then we can change this for you.

About your changes in the guide, the part "When a visitor connects to your website and is not logged-in (User ID is not set)" is still wrong when the option is enabled (this is the purpose of this issue).

@mattab @peterbo I copied into the guide the original docs that were there before changing the behaviour in Matomo 3.13 or so. Do you know what is expected here or how it works? I think the code is likely right but the docs aren't correct.

@AAudusseau
Copy link
Author

Just FYI if you're using Matomo Cloud then we can change this for you.

Yes that would be perfect, my instance is located at https://opc.matomo.cloud Thanks!

@peterbo
Copy link
Contributor

peterbo commented Dec 16, 2020

I copied into the guide the original docs that were there before changing the behaviour in Matomo 3.13 or so. Do you know what is expected here or how it works? I think the code is likely right but the docs aren't correct.

This should be how it works when it is enabled (userID overwrites visitorID). @AAudusseau what is exactly happening, when you're trying the use case?

Can be quite different, if you do those requests Server-to-Server, because the server doesn't use a cookie for recognition, after you don't pass the UserID anymore with the request.

@AAudusseau
Copy link
Author

Right now when the enable_userid_overwrites_visitorid option is enabled, when the visitor logs-in the existing previous visits (login page for instance) are not re-used, so the result is one user, 2 visits, one unique visitor.

image

In red the login page visit (no userID set), and in green authenticated pages (userID set).

@tsteur
Copy link
Member

tsteur commented Dec 16, 2020

Yes that would be perfect, my instance is located at https://opc.matomo.cloud Thanks!

Hi @AAudusseau we'll be happy to make that change. Could you contact support@matomo.cloud for this change? Just so we can verify that you are the owner of that account.

@Atala
Copy link

Atala commented Feb 22, 2021

I have the same issue. I don't understand why having enable_userid_overwrites_visitorid = 0 would fix this behavior. If I understand correctly the docs the behavior @AAudusseau and I wants is enable_userid_overwrites_visitorid = 1 (matomo 4 default). According to the docs :

When “User ID overwrites Visitor ID” feature is enabled

When a visitor connects to your website and is not logged-in (User ID is not set) then a visit is created. If the visitor then logs-in your website and has a User ID set then their existing visit will be re-used (the visit without User ID that is created when the user was not logged in yet). All requests where this User ID is set will all be added into this same visit. Result: one user, one visit, one unique visitor. (if User ID was not used it would also have created one visit and one unique visitor).

(ref: https://matomo.org/docs/user-id/#when-user-id-overwrites-visitor-id-feature-is-enabled)

so I think the docs is still not correct ? or other bug

I contacted support as well

@AAudusseau
Copy link
Author

@Atala the doc has not changed so I agree it is still incorrect.

@nogamenofun98
Copy link

nogamenofun98 commented Jun 27, 2023

I got this issue also, my config for enable_userid_overwrites_visitorid is set to 1, and when a guest visit website and created a visitor profile record, after they login later on, another visitor record is created, and the old record doesnt merge together.

So, about this enable_userid_overwrites_visitorid, I need to set to 0 or 1 if I want to merge all visitor profile record together when user is logged in later on?

EDITED: I had tried to set it to 0, and it does merge together, but If I want to record diff device, same user, as same record, that will be not an option anymore because i set it to 0?
How can I let it merge all visitor log based on logged user id with record diff device as same record at the same time?

@heurteph-ei
Copy link

Hi @nogamenofun98
Maybe have a look at: #19927

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

7 participants