diff --git a/js/piwik.js b/js/piwik.js index c35279924c40f6ba513076ac7cc8875054bd18e4..6ba9d3dc04180556f075e37989ae6e8475d454c1 100644 --- a/js/piwik.js +++ b/js/piwik.js @@ -2811,7 +2811,7 @@ if (typeof Piwik !== 'object') { } newVisitor = id[0]; - uuid = id[1]; + uuid = asyncTracker.getVisitorId(); createTs = id[2]; visitCount = id[3]; currentVisitTs = id[4]; @@ -4082,7 +4082,7 @@ if (typeof Piwik !== 'object') { * @return string Visitor ID in hexits (or null, if not yet known) */ getVisitorId: function () { - return (loadVisitorIdCookie())[1]; + return configUserId ? sha1(configUserId).substr(0, 16) : (loadVisitorIdCookie())[1]; }, /** diff --git a/tests/javascript/index.php b/tests/javascript/index.php index b4e737792d5621f6a841298bfb38f4639885cc64..a23a521c746c09a8e68ce7a7c4c71848836b0eec 100644 --- a/tests/javascript/index.php +++ b/tests/javascript/index.php @@ -2586,7 +2586,7 @@ if ($sqlite) { }); test("tracking", function() { - expect(102); + expect(103); /* * Prevent Opera and HtmlUnit from performing the default action (i.e., load the href URL) @@ -2829,6 +2829,7 @@ if ($sqlite) { tracker3.setUserId(userIdString); equal(userIdString, tracker3.getUserId()); + equal(tracker.hook.test._sha1(userIdString).substr(0, 16), tracker3.getVisitorId()); // Append tracking url parameter tracker3.appendToTrackingUrl("appended=1&appended2=value");