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

wrong value returned by getVisitorId() #2643

Closed
anonymous-matomo-user opened this issue Sep 3, 2011 · 8 comments
Closed

wrong value returned by getVisitorId() #2643

anonymous-matomo-user opened this issue Sep 3, 2011 · 8 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Milestone

Comments

@anonymous-matomo-user
Copy link

Steps to reproduce:

  1. Go to a piwik 1.5.1 tracked page.
  2. Clear recent history (Cookies, etc..)
  3. Reload the page.

The call to getVisitorId returns the value stored inside the newly created cookie (= the _id GET parameter in the call to piwik.php), instead of the idvisitor determined from the config and saved in the piwik_log_visit table.

In my config I have:
tracker_always_new_cookie = 0

use_third_party_id_cookie = 1

trust_visitors_cookies = 0

@robocoder
Copy link
Contributor

The cookies are not compatible with each other, plus the third-party cookie can also be named differently (via cookie_name).

@anonymous-matomo-user
Copy link
Author

Replying to vipsoft:

The cookies are not compatible with each other
1st and 3rd party cookies are not compatible? Why is there a use_third_party_id_cookie flag then?
plus the third-party cookie can also be named differently (via cookie_name).
I kept the default value
cookie_name = piwik_visitor

@robocoder
Copy link
Contributor

piwik.js uses a first-party, client-side generated cookie. It doesn't understand the format of the third-party, server-side generated cookie.

@anonymous-matomo-user
Copy link
Author

Ok, thanks I got it, so it's a normal behaviour then: I thought that getVisitorId() was making an Ajax call, instead of just reading first-party cookie.
However, when I clear recent history, both cookies are deleted and piwik still records the visit under the previous idvisitor, by matching config/IP. So the question is how can I get the real idvisitor value (under which the visit will be stored)? I mean is it possible to get it from the server with Ajax?

@robocoder
Copy link
Contributor

No, retrieving the visitor ID by AJAX isn't possible, and I'm not sure if it's planned given the security considerations and bulk loading contemplated in #134.

@anonymous-matomo-user
Copy link
Author

Hmm, ok. Now that I think about it, I suppose it is always possible to select recent rows inside piwik_log_visit table, and then filter by IP to retrieve idvisitor value with more or less success... Anyway thanks for the explanations and a prompt response.

@mattab
Copy link
Member

mattab commented Sep 6, 2011

Just to clarify the default use case (no 3rd party cookies): When you refresh the page with no cookie, Piwik will generate a new visitor ID on the client side (1st party cookie), since you don't have any cookie. Then it will send this cookie value to the server and the log_visit row for this visit should be updated with the newly created idvisitor.

@anonymous-matomo-user
Copy link
Author

It's still valid in 2.3.0

So never use "use_third_party_id_cookie" setting, when u are tracking also in your backend (e.g. PHP) Otherwise your user will be counted twice.

Solution / Idea?

  • read from piwik.js the 3rd party cookie and write it from the inline js to the 1st party cookie? (is this possible?)

@anonymous-matomo-user anonymous-matomo-user added this to the 1.6 Piwik 1.6 milestone Jul 8, 2014
@mattab mattab added the wontfix label Aug 3, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. wontfix If you can reproduce this issue, please reopen the issue or create a new one describing it.
Projects
None yet
Development

No branches or pull requests

3 participants