@itmagpro opened this Issue on December 28th 2019

I use latest matomo 3.13.0

I read:

............................................................
Tracking HTTP API: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3
https://developer.matomo.org/api-reference/tracking-api

JavaScript Tracking Client: Integrate - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3 - User ID
https://developer.matomo.org/guides/tracking-javascript-guide#user-id

User ID

User ID is a feature in Matomo that lets you connect together a given user's data collected from multiple devices and multiple browsers.
............................................................

I want to use this "User ID feature" and set code in my site:

............................................................
<?php
...
@$uid = substr(sha1($_SERVER['REMOTE_ADDR'].$_SERVER['HTTP_USER_AGENT'].$_SERVER['HTTP_ACCEPT_LANGUAGE']), 0, 16);
...
?>

<!-- Matomo -->
<script type="text/javascript">
  var _paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(["setCookieDomain", "*.example.com"]);
  <?php echo sprintf("_paq.push(['setUserId', '%s']);", $uid); ?>
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  ...
</script>
<!-- End Matomo Code -->

<noscript>
<!-- Matomo Image Tracker -->
<img src="https://example.com/piwik.php?idsite=2&amp;rec=1&amp;url=<?php echo rawurlencode(JUri::getInstance()); ?>&amp;action_name=<?php echo rawurlencode('[noscript] '.$document->title); ?>&amp;send_image=0&amp;urlref=<?php echo rawurlencode(@$_SERVER['HTTP_REFERER']); ?>&amp;uid=<?php echo rawurlencode($uid); ?>&amp;cid=<?php echo rawurlencode($uid); ?>" style="border:0" alt="" />
<!-- End Matomo -->
</noscript>
............................................................

In config.ini.php window_look_back_for_visitor var I set to 86400, see my full config.ini.php: https://pastebin.com/KG8FBQHy

But, when I looked statistic:

............................................................
Суббота, 28 декабря 2019 г. - 23:24:12
IP: 188.127.251.xx
Россия

Profile ID (aka uid): d2f22ac701961993
Visitor ID (aka cid): 8cbf24c93d0f4628

Прямой вход
Провайдер: Неизвестно

...............

Суббота, 28 декабря 2019 г. - 23:42:17
IP: 188.127.251.xx
Россия

Profile ID (aka uid): d2f22ac701961993
Visitor ID (aka cid): c3f6fec89ef58cb4

Прямой вход
Провайдер: Неизвестно
............................................................

I see, that same one visitor from same IP, with device and same "Profile ID" (d2f22ac701961993) counted/tracked as unique visitor instead as "Returned visitor" ;(

User ID is feature in Matomo or bug? How to fix this bug?

This bug appear for user which disable cookies, then matomo for same uid (d2f22ac701961993) generate different cid (8cbf24c93d0f4628 | c3f6fec89ef58cb4) for each visit.

Related topics for this problem:

New visit created for each action with userid populated since 3.13 · Issue #15299 · matomo-org/matomo · GitHub
https://github.com/matomo-org/matomo/issues/15299

New visit created for each action with userid populated since 3.13 · Issue #28 · matomo-org/piwik-java-tracker · GitHub
https://github.com/matomo-org/piwik-java-tracker/issues/28

@tsteur commented on December 29th 2019 Member

Any chance in your config/config.ini.php there is a setting named trust_visitors_cookies enabled? Even when the cookie changes Matomo should still be able to identify the visitor as the same even if visitorId changes.

@itmagpro commented on December 30th 2019

tsteur - as you see reference on pastebin in my config/config.ini.php trust_visitors_cookies not present, in config/global.ini.php trust_visitors_cookies = 0 You right about "Matomo should", but in this/my case Matomo NOT identify the visitor as the same even if visitorId changes and tracked as "Multiple unique visit for each action for same User ID". config/global.ini.php see here: https://pastebin.com/2zBfLSEh

@tsteur commented on December 30th 2019 Member

@itmagpro this looks like the content of config/global.ini.php is that correct?

@tsteur commented on December 30th 2019 Member

@itmagpro I think I can reproduce it by adding this tracking code:


        _paq.push(['disableCookies']);
        _paq.push(['setUserId', 'foo']);
@tsteur commented on December 30th 2019 Member

It seems Matomo JS tracker is not sending a visitorId when cookies are disabled. I think it should rather generate one randomly @mattab @sgiehl @diosmosis ? And then it will recognize visitor through configId?

In my case every action creates a new visit

@diosmosis commented on December 31st 2019 Member

@tsteur From the issue description there is a visitor ID that's being sent but it changes, which would make sense if cookies were disabled since it wouldn't be able to store the visitor ID, correct? I wonder why the configId isn't being matched, maybe there's something else we store in cookies that is used to compute the config ID.

The new visitor ID w/ disabled cookies I think is expected behavior after merging #14360, and the config ID is supposed to still match those visitors properly, so there must be a problem w/ the config ID... though I'm not sure what, the code looks ok...

@tsteur commented on January 1st 2020 Member

The problem is that it checks and userId is null when matching configId here: https://github.com/matomo-org/matomo/blob/3.13.1-b1/core/Tracker/Model.php#L404-L405

I suppose this is not really needed anymore @diosmosis @mattab ?

Also just realising the query above (findVisitorByVisitorId) for visitorId is not needed when visitorId is empty ... should be maybe improved in the same PR

@diosmosis commented on January 1st 2020 Member

👍 makes sense to remove the userId is null check. Can pick the issue upf if needed.

@tsteur commented on January 1st 2020 Member
This Issue was closed on January 2nd 2020
Powered by GitHub Issue Mirror